[REBOL] Re: Another newbie VID question
From: ingo:2b1 at: 4-Oct-2003 21:55
Hi Kai,
Kai Peters wrote:
> Hi all ~
>
> am wondering why my code below doesn't work
>
> toggle_start: toggle 60 "Start"
> [
> flash "we get here"
> toggle_start/text: "Stop"
> show toggle_start
> ]
>
> What do I need to make a toggle switch between "Start" and "Stop" every time I press
it?
> Where do I need to look to find which refinements a toggle has? Does it have a 'down'
or 'pressed' ?
This is the answer ...
REBOL[]
view layout [toggle_start: toggle 60 "Start"
[
;help face
face/text: pick ["Stop" "Start"] face/data
show face
]
]
And here comes the explanation ...
Those vid action blocks are turned into functions with the face itself as
an argument, named face (be careful, sometimes it's only 'f, IIRC).
Now, the commented out "help face" gave me a quick look at what the face
contains, among a lot of other things, I found that there's face/data, a
boolean value, so I decided "that's it".
your toggle_start/text: part was already ok (I just decided to use the
word 'face, because it's shorter, and dag'n'droppable ;-) , now we just
have to toggle the text depending on face/data (this feature of 'pick has
been the source of many long and lively discussions, but it makes for nice
short code).
I hope that helps,
Ingo