Send and Dispatch without parameters

dunbarx at aol.com dunbarx at aol.com
Fri Jan 27 16:39:33 EST 2012


This is not normal. The method works for me, and has, basically, since 1987.


But I tried it in both a new stack and in a stack filled with other stuff, a test stack of mine with all sorts of things in it. The simple command worked as advertised in the new stack, but failed in the test stack as you described. Not sure yet what is happening.


This is the most basic of all message hierarchy machinations; it has to work in all the variations you mentioned.


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

 



More information about the use-livecode mailing list