Dispatch does not switch context
Posted: Fri Oct 18, 2013 11:09 am
Hello everybody,
I'm new to livecode and I'm trying to understand the differences between "call", "send", "dispatch" for functions and commands etc. In the livecode lesson "How to call a function or command in another object?", it is stated that:
As with "send", "dispatch" temporarily switch context when the target handler is executing.
but it doesn't seem to happen this way:
if I create a stack with 2 cards and on the first one I add a button with script:
on mouseUp
Dispatch "printmynumber" to card 2 of this stack
end mouseUp
and on the second card, I put this in the card's script:
command printmynumber
answer the id of this card
end printmynumber
So if the context is temporarily switched when executing the dispatched command, I would get the id of the second card when I click on the button on the first card,but I actually get the id of the first card. What can I do to actually get the id of the second card? (this is just an axample, actually I want to do many other things but in the context of the card where the command resides)
Thank you for your help!
Marie
P.S. the same happens if I use "send" instead of "dispatch"
I'm new to livecode and I'm trying to understand the differences between "call", "send", "dispatch" for functions and commands etc. In the livecode lesson "How to call a function or command in another object?", it is stated that:
As with "send", "dispatch" temporarily switch context when the target handler is executing.
but it doesn't seem to happen this way:
if I create a stack with 2 cards and on the first one I add a button with script:
on mouseUp
Dispatch "printmynumber" to card 2 of this stack
end mouseUp
and on the second card, I put this in the card's script:
command printmynumber
answer the id of this card
end printmynumber
So if the context is temporarily switched when executing the dispatched command, I would get the id of the second card when I click on the button on the first card,but I actually get the id of the first card. What can I do to actually get the id of the second card? (this is just an axample, actually I want to do many other things but in the context of the card where the command resides)
Thank you for your help!
Marie
P.S. the same happens if I use "send" instead of "dispatch"