"send mouseUp to…" vs "click at the loc of..".
Richard Gaskin
ambassador at fourthworld.com
Fri Jan 3 15:01:58 EST 2014
Richmond wrote:
> On 03/01/14 20:17, Richard Gaskin wrote:
>> Stephen Goldberg wrote:
>>
>> > Just a note about a discovery I just made, in case it is not
>> > generally known: The speed of a script, especially when
>> > dealing with many cards, is improved significantly by writing
>> > "send mouseUp to…" instead of "click at the loc of…"
>>
>> Using "dispatch" is even faster, and faster still (and often more
>> robust) is for both scripts to make a direct call to a handler defined
>> further along the message path.
>
> Really?
>
> It seems that 'dispatch' has more capabilities than 'send':
It's slightly faster than "send", and makes for a more natural and
robust way to send arguments using "with", e.g.:
dispatch "resizeStack" with 800,600
Dispatch also follows a path more akin to built-in messages, in that an
unhandled custom message will fail silently (you can check "the result"
for "message not handled"), while with "send" it would throw an error.
But of the two, only "send" supports a "in <time>" option, so for timers
we still need it.
> When I tried this:
>
> on mouseUp
> dispatch function "mouseUp" to btn "XYZ"
> end mouseUp
>
> NOTHING happened
MouseUp is a command, so the function specifier won't work there.
But as you discovered:
> now btn "XYZ" contains a function:
>
> function BlastMySocks
> put "socks blasted"
> end BlastMySocks
>
> and when I put this into the script of my other button:
>
> on mouseUp
> dispatch function "BlastMySocks"
> end mouseUp
>
> the function is executed
>
> THAT is not possible with 'send'
>
> -----------------------------------
>
> Well, I don't know about anybody else, but I am very grateful to Richard
> Gaskin for having taught me something about Livecode I don't know after
> about 12 years with it, plus 10 with Hypercard, and a nagging feeling that
> I look quite a twerp not having known that already!
And I have to thank you here, because since I rarely read docs I didn't
know dispatch could be used like "call" to trigger functions. Very
handy. Thanks!
--
Richard Gaskin
Fourth World
LiveCode training and consulting: http://www.fourthworld.com
Webzine for LiveCode developers: http://www.LiveCodeJournal.com
Follow me on Twitter: http://twitter.com/FourthWorldSys
More information about the use-livecode
mailing list