Caution when using "send" in an "openCard" handler
Jim Hurley
jhurley at infostations.com
Thu Jan 2 05:43:00 EST 2003
I'm sure the old hands with MC/Rev are familiar with this issue but
it was news to me.
Create two cards.
In the second card place one button and one field.
Put the following handler in the button:
on mouseup
beep
put the tool & return after field 1
end mouseup
And the following handler in the card script:
on opencard
put empty into field 1
put "pointer,line,image,browse,button,pencil" into someTools
repeat with i = 1 to the number of items in someTools
choose the (item i of someTools) tool
send "mouseUp" to button 1
end repeat
end opencard
Now go from card 1 to card 2. This will call the "openCard" handler
in the second card. I get only one beep and only "browse tool"
appears in the field; no error message is generated.
It seems that the "send" message is received by the button on card 2
(from the "openCard" handler) only when the "browse" tool is selected.
The selected tool does not appear to matter when the "send" message
is sent from one button to another button; the problem appears only
(?) when it comes from the "openCard" handler in the card script.
I have added to my new year's resolutions: Don't send messages to
buttons in an openCard handler unless the browse tool is selected.
With respect to all other character-building resolutions, I subscribe
to Oscar Wilde's observation:
"Good resolutions are simply checks that men draw on a bank where
they have no account."
--
Jim Hurley
More information about the use-livecode
mailing list