field action unfocuses field
[1/2] from: arolls:bigpond:au at: 23-Jul-2001 6:53
Does anyone know how to reset
the focus to the same field after
it has completed its action?
See this example doesn't work:
view center-face layout [
f: field [
print ["f is focused. waiting 3 seconds"]
focus f ; this works, great
wait 3 ; time for you to see it is focused ok
focus f ; gets unfocused straight after this
]
do [focus f] ; focus on f first time
]
[2/2] from: g::santilli::tiscalinet::it at: 23-Jul-2001 18:52
Hello Anton!
On 22-Lug-01, you wrote:
A> Does anyone know how to reset
A> the focus to the same field after
A> it has completed its action?
I have found this quite annoying in some cases so I wrote a patch.
I don't know if this thing should be released publicly (made to
suit personal needs only, no docs, etc.), but well, let's do it!
NAF-Field will keep its focus if your action does not change it
manually. To handle TABs, you can write:
NAF-Field refocus 'prev-field 'next-field
(as words, mainly because usually you don't have next-field
already defined at this point)
NAF-Field refocus [either shift ["SHIFT TAB"] ["TAB"]]
(here you can do whatever you want --- this is a VID feature
actually)
You'll find other things, but you might simply strip them off or
ignore them.
HTH,
Gabriele.
--
Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer
Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/
REBOL [
Title: "VID styles patches"
Author: "Gabriele Santilli <[giesse--writeme--com]>"
File: %vid-patches.r
Date: 11-Jun-2001
Version: 1.1.0 ; majorv.minorv.status
; status: 0: unfinished; 1: testing; 2: stable
History: [
11-Jun-2001 1.1.0 "History start"
]
]
; fix to avoid auto refocus after action on fields
context [
chg: c: second get in ctx-text 'edit-text
either 6717985 = checksum mold c [
chg: compose [(chg: copy/part at c/20/9/22/5 10 3) not (chg)]
change back tail chg 'no-auto-focus
remove change/only change at c/20/9/22/5 10 'all chg
] [print "CANNOT APPLY NAF PATCH!"]
]
; useful wait-for function
context [
screen-pane: system/view/screen-face/pane
normal: end-waiting?: does [
empty? screen-pane
]
when-waiting: does [
not found? find screen-pane waiting-for
]
; to make wait-for work
c: pick second get in system/view 'wake-event 12
either 11815557 = checksum mold c [
clear change at c 3 [end-waiting?]
] [print "CANNOT APPLY WAIT-FOR PATCH!"]
wait-list: []
waiting-for: none
set 'wait-for func [window [object!]] [
insert tail wait-list waiting-for: window
end-waiting?: :when-waiting
wait []
remove back tail wait-list
either not empty? wait-list [waiting-for: last wait-list] [end-waiting?: :normal]
]
]
context [
focus-patch: [
refocus: none
flag-face self no-auto-focus
insert tail words compose [
refocus (func [new args] [
parse args [
'refocus args: block! (new/refocus: func [shift] args/1)
| 'refocus word! args: word! (
new/refocus: func [shift] compose/deep [
focus either shift [(args/-1)] [(args/1)]
]
)
| args:
]
args
])
]
]
field-feel: none
stylize/master [
; nicer choice
Choice: Choice effect [gradient 0x1 66.120.192 44.80.132] edge [color: 142.128.110] feel
[
engage: func [face action event] [
if action = 'down [
event: face/effect
face/effect: none
choose/style/window face/texts func [face parent] [
parent/text: face/text
parent/data: find parent/texts face/text
do-face parent none
] face face/parent-face
face/effect: event
]
show face
]
]
; these are nicer this way too, and allow alt-action
Field: Field edge [color: 142.128.110] with [
set 'field-feel feel: make feel [
use [c] [
c: second :engage
either 5084208 = checksum mold c [
insert c/3 bind [alt-up [do-face-alt face face/text]] c/2
] [print "CANNOT APPLY FIELD ALT-ACTION PATCH!"]
]
]
]
Area: Area edge [color: 142.128.110] with [
feel: field-feel
]
; NO AUTO FOCUS field and area
NAF-Field: Field with focus-patch
NAF-Area: Area with focus-patch
; fixing a bug in Slider/redrag
Slider: Slider with [
use [c] [
c: second :redrag
either 8177867 = checksum mold c [
insert c [state: none]
] [print "CANNOT APPLY SLIDER PATCH!"]
]
]
; List edge...
List: List edge [color: 142.128.110]
]
]