Trapping the Option or Command keys

SparkOut SparkOutYNY at gmail.com
Tue Jul 28 06:45:44 EDT 2009



Sarah Reichelt-2 wrote:
> 
> On Tue, Jul 28, 2009 at 8:52 AM, <DunbarX at aol.com> wrote:
>> Sarah:
>>
>> Just curious. Do you use "command" instead of (good ol') "on"?
>>
> 
> "command" was introduced in 3.? (3.5 I think) and I am gradually
> training myself to use it.
> The idea is that system messages still use "on", so you have "on
> mouseUp", "on preOpenStack" etc.
> But your own handlers use "command" instead of "on" to make it clearer
> what's what.
> "function" remains unchanged.
> 
> However it's just a matter of style, I don't think either way is
> inherently more correct and as far as I know, RunRev is not going to
> make either one compulsory any time soon.
> 
> Cheers,
> Sarah
> 
"command" has been around since before I started with Rev (2.7) - in the
dictionary it says it was introduced in version 1.0!
When I first started I defined every "command handler" with "command" as I
couldn't clearly see what was meant by "on" but as I got exposed to the
language I got used to "on" and adopted it (as well as "command" - see
below).
I think one of the main significant things is that you can define a "private
command <handler>" but (from the docs) "Note: Although it is also possible
to use "on" when declaring a private handler this is not recommended as it
implies that the handler is a message sent when some event occurs. As
private handlers are not passed through the message path, this is incorrect
and can make the code harder to understand. Please see the on control
structure entry for more details."
It is really a matter of style, as Sarah says. I have sort of got a hazy
policy of using "on" for handlers where I'm expecting a message to be passed
up the path and handled "on" an event, and command (or private command) for
handlers which are more just modular procedures (eg setup defaults) and/or
like a function that doesn't return a value. I certainly don't get overly
picky about the choice.
-- 
View this message in context: http://www.nabble.com/Trapping-the-Option-or-Command-keys-tp24685348p24696836.html
Sent from the Revolution - User mailing list archive at Nabble.com.




More information about the use-livecode mailing list