A curious fact about menuPick handlers
Robert Brenstein
rjb at robelko.com
Wed Mar 16 08:04:52 EST 2005
>I'm debugging a menu, and I made the mistake of not catching a
>particular menuItem - i.e. there was no specific case for this item
>in my switch statement in my menuPick handler, and I didn't have a
>default case statement (why would I?).
>
>I put a breakpoint on the first line of the menuPick handler, i.e. at
>
>on menuPick
>
>but when I invoked the menuItem that wasn't allowed for in my switch
>statement, the handler never fired at all, so I couldn't see what
>was wrong. Absolutely nothing happened - it's as if the engine had
>done a quick scan of the menu items and said "this guy doesn't know
>what to do with this item so I won't even start the handler". When I
>put a default case in with a breakpoint, then the script opened for
>debugging at that point.
>
>I guess it's obscure, but I did not expect this to happen: maybe
>other people might get caught the same way.
>
>Graham
And it does not fire when you add the default case? That would be curious.
Having a default case displaying an error dlog is usually a good
idea: does not cost anything (except typing a few lines) but catches
typos and other mismatches.
Robert
More information about the use-livecode
mailing list