[REBOL] Re: IRSee.r now with ENCRYPTED white board.
From: arolls:bigpond:au at: 10-May-2001 5:12
Look at this code:
; example 1
view layout [button "L" 16x16 [wait 2]]
; example 2
view layout [button "L" 16x16 [forever [wait 3]]]
In example 1, you can press the button, then quit straight away,
and you have control at the console. That makes me think that
wait can be interrupted by a 'quit event (or something like that).
In example 2, you press the button, it should wait forever right?
No, the window is still receiving events. You can move the mouse
over and away from the button and it reacts, the close button
works too. I think wait listens to the window events.
I think example 2 is an example you should never try to implement
in your program, because you are trying to block window events ;)
Anyway, I recommend, in your code below, that you use 'rate 1...
First I think something like this:
do-it?: no
view layout [
button "L" 16x16 [do-it?: yes]
rate 1 feel [engage: func [face event action][
if event = 'time [print if do-it? ["show"]]
]
]
]
but I have killed button's nice and useful feel function
that listens to me when I click mouse on it etc...
So I get the button style code like this:
probe get-style 'button
Copy and paste the code inside:
feel: make object! [ ... get this code here ... ]
And this monster of a hack is what I end up with:
do-it?: no
view layout [
button "L" 16x16 [print "hello" do-it?: yes]
rate 1 feel [
redraw: func [face act pos /local state][
face/edge/effect: pick [ibevel bevel] face/state
if face/texts [face/text: face/texts/1]
all [face/state face/texts face/text: any [face/texts/2
face/texts/1]]
state: either not face/state [face/blinker] [true]
if face/colors [face/color: pick face/colors not state]
if face/effects [face/effect: pick face/effects not state]
]
detect: none
over: func [face action event][
if all [face/font face/font/colors] [
face/font/color: pick face/font/colors not action
show face
face/font/color: first face/font/colors
]
]
engage: func [face action event][
switch action [
time [
print if do-it? ["show"] ; <-- this is our addition
if not face/state [face/blinker: not face/blinker]
]
down [face/state: on]
alt-down [face/state: on]
up [if face/state [do-face face none] face/state: off]
alt-up [if face/state [do-face-alt face none] face/state:
off]
over [face/state: on]
away [face/state: off]
]
cue face action
show face
]
cue: none
blink: none
]
]
Notice the change inside the engage function...
I hope this helps.
Maybe someone can suggest a better way to insert that one
line into the engage function.
Actually, maybe I can do it.
Do each line here as I have done.
probe get-style 'button
probe get in get-style 'button 'feel
probe get in get in get-style 'button 'feel 'engage
Engage is a function, so to get the function body, we use second:
probe second get in get in get-style 'button 'feel 'engage
We are interested in the third item, ('switch is first, 'action second).
probe third second get in get in get-style 'button 'feel 'engage
Finally, the 'time code is in here.
probe select third second get in get in get-style 'button 'feel 'engage
'time
All we have to do is modify a copy of the button style.
Petr Krenzelok showed us how to copy a style back in 14-Nov-2000,
in rebol list.
Err... I'm losing it... can't stay awake .. any longer...
Anton.