Send and Dispatch without parameters

Bob Sneidar bobs at twft.com
Fri Jan 27 17:18:46 EST 2012


Wait I just thought of why it seemed to not work. In the mouseUp code I had the conditional "if pMouseBtnNum is 1 then...". DUH! If I don't pass 1 as a parameter, nothing inside the conditional will execute! Criminy that was stupid. 

Bob


On Jan 27, 2012, at 1:46 PM, DunbarX at aol.com wrote:

> Bob.
> 
> 
> Nope, it was me. Name conflict; you don't want to know.
> 
> 
> The method works fine. LC messages like "mouseUp" or custom ones like "yourMessage" all pass correctly. Parameters are not pertinent. Check your stack. I had another object with the same name as the intended target. My message was passed all right, but to the wrong destination.
> 
> 
> Craig Newman
> 
> 
> -----Original Message-----
> From: Bob Sneidar <bobs at twft.com>
> To: How to use LiveCode <use-livecode at lists.runrev.com>
> Sent: Fri, Jan 27, 2012 3:57 pm
> Subject: Send and Dispatch without parameters
> 
> 
> Hi all. 
> 
> I just noticed that if you send or dispatch to an object and you have specified 
> parameters in the objects handler, but you don't provide the parameters when you 
> send or dispatch, the call will silently fail. This seems only to occur for 
> built in handlers, like mouseUp for example. 
> 
> If I have a button called "myButton" with a mouseUp handler:
> 
> on mouseUp pButtonNum
>    put "This is a test"
> end mouseUp
> 
> if I:
> send "mouseUp" to button "myButton"
> 
> or:
> dispatch "mouseUp" to button "myButton" 
> 
> The button will never get the message, and no error is generated. This caught me 
> quiet off guard, as you can for a custom handler just call it, and even if you 
> don't provide all the parameters, the handler gets called anyway. 
> 
> However, if I have a custom handler:
> 
> on testMe theMessage
>    put "This is a successful test."
> end testMe
> 
> And then I send or dispatch without the parameter, the handler gets called fine! 
> Is this normal or expected behavior? I cannot think that this kind of ambiguity 
> is what the devs intended. If someone can give me a reason for why it has to be 
> this way, I can just watch for it in the future. If not I suppose I should 
> submit a bug report. 
> 
> In the meantime, I suppose the best practice is to never put the business end of 
> your code in the built in handlers, but rather call a command or function that 
> does all the work. That way you can send or dispatch to that handler and not to 
> the built in one. 
> 
> Bob
> 
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list