Another newbie stumper
[1/2] from: kpeters::mvinc::net at: 24-Feb-2004 20:50
Hi All ~
Below is a code snippet that has me stumped:
When I click the toggle, everything works fine.
However, pressing the hot key CTRL-s generates the error below -
shouldn't the hot key do exactly what a left click does?
Thansk for any help,
Kai
snip....
toggle_start: toggle 60 "Start" "Stop" mint #"^s"
[
face/color: pick reduce [ sienna mint ]
face/data
show face
scanning?: pick reduce [ yes no] face/data
]
snip....
** Script Error: pick expected index argument of type: number logic
** Where: func [face value][
face/color: pick reduce [sienna mint] face/data
show face
scanning?: pick reduce [yes no] face/data
]
** Near: face/color: pick reduce [sienna mint] face/data
[2/2] from: carl:cybercraft at: 25-Feb-2004 14:51
On 25-Feb-04, Kai Peters wrote:
> Hi All ~
> Below is a code snippet that has me stumped:
> When I click the toggle, everything works fine.
> However, pressing the hot key CTRL-s generates the error below -
> shouldn't the hot key do exactly what a left click does?
No - all it does is evaluate the style's block. The toggling and
other effects are handled by the face's feel functions. To see
toggle's feel, enter this at the console...
layout [t: toggle] probe t/feel
One way to achieve what you want would be to add a feel block to your
style and then place a copy of the engage function in it, but with
the line that does the toggling moved to the evaluation block. ie,
like this (watch for line-wrap)...
view layout [
toggle_start: toggle 60 "Start" "Stop" mint #"^s" feel [
engage: func [face action event][
if find [down alt-down] action [
if face/related [
foreach item face/parent-face/pane [
if all [flag-face? item toggle item/related
item/related = face/related item/data] [item/data: item/state: false
show item]
]
]
; face/data: face/state: not face/state
either action = 'down [do-face face none] [do-face-alt
face none]
; show face
]
]
]
[
face/data: face/state: not face/state
show face
]
]
There "show face" has also been moved, since it would be redundant if
left in the function. You can now add your color-changing code to
the block before the "show face".
HTH.
Carl Read.
> Thansk for any help,
> Kai
<<quoted lines omitted: 14>>
> ]
> ** Near: face/color: pick reduce [sienna mint] face/data
--
Carl Read
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted