CommandKeyDown in a library script?

Peter Haworth pete at lcsql.com
Fri Jul 18 13:15:40 EDT 2014


This comes up on the list every few months.  It bit me a while back and
cost me a couple of hours of frustration and level 6 or 7 cursing (on a
scale of 1 to 10 with 1 being the mildest and 10 being the most profane)
trying to figure out why the code in my handler wasn't being executed and
didn't even respond to debug breakpoints.

Craig's reply about this being useful for trying out different versions of
the same handler is the usual justification for it but I personally don't
buy it.  If you want to do that it's just as easy to comment out all
versions of the handler except the one you want to execute.

The fact that the duplicate handlers aren't flagged in some way makes it
even harder to deal with this.  Perhaps the script editor's list of
handlers should either list the handler twice or include how many versions
of it are in the script in parens after the handler name or something.

Since some folks take advantage of this "feature", perhaps a duplicate
handler name should not be flagged as an error unless Strict Compile Mode
is on to accommodate those of us who think it is a bug.

Pete
lcSQL Software <http://www.lcsql.com>
Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>


On Fri, Jul 18, 2014 at 8:16 AM, Graham Samuel <livfoss at mac.com> wrote:

> Hmm
>
> I was unaware of this feature and so have never used it, but it does seem
> to me a recipe for undetected errors. However ancient the tradition, I
> still think the IDE owes us a warning, perhaps only in 'strict compile'
> mode.
>
> My two (euro) cents
>
> Graham
>
> Sent from my iPad
>
> > On 18 Jul 2014, at 15:52, dunbarx at aol.com wrote:
> >
> > Graham.
> >
> >
> > Since 1987 you have been allowed as many similarly named handlers in a
> script, and certainly among the objects in a stack. If within a script,
> only the first one is exectuted by the engine.
> >
> >
> > This is acutally a good thing. You can try several variants of a
> handler, arranged one after the other, and test them, commenting out the
> ones above the one of current interest.
> >
> >
> > Craig
> >
> >
> >
> > -----Original Message-----
> > From: Graham Samuel <livfoss at mac.com>
> > To: How to use LiveCode <use-livecode at lists.runrev.com>
> > Sent: Fri, Jul 18, 2014 5:01 am
> > Subject: Re: CommandKeyDown in a library script?
> >
> >
> > Craig - sorry, forgot to thank you for this. Yes, there was another
> handler
> > further up the library which I didn't notice. The IDE did not complain
> that I
> > had two identically-named handlers in the same script, which seems odd
> to me. I
> > wonder if it's a bug? I think the IDE used to complain about this,
> didn't it? It
> > certainly doesn't now (just to be sure, I just added an "openStack"
> handler to a
> > stack script which already has one, and it compiled without errors). I'm
> using
> > LC 6.6.2.
> >
> > Thanks again
> >
> > Graham
> >> On 16 Jul 2014, at 05:51, dunbarx at aol.com wrote:
> >>
> >> Graham.
> >>
> >>
> >> It should. It always has for me.
> >>
> >>
> >> Is the handler in the library stack in the stack script? It has to be,
> unless
> > you send it explicity to a card or control on that stack. Are you sure
> you are
> > not trapping it anywhere in the main stack? Or if you are, are you sure
> you are
> > passing the message?
> >>
> >>
> >> Craig
> >>
> >>
> >>
> >> -----Original Message-----
> >> From: Graham Samuel <livfoss at mac.com>
> >> To: How to use LiveCode <use-livecode at lists.runrev.com>
> >> Sent: Tue, Jul 15, 2014 1:51 pm
> >> Subject: CommandKeyDown in a library script?
> >>
> >>
> >> When I create a new mainstack and put a commandKeyDown handler in it,
> the
> >> handler fires when I press the relevant key. When I put the same code
> in a
> >> library stack, which is used via a "start using" command at
> initialisation, it
> >
> >> doesn't seem to fire. Can anyone say why?
> >>
> >> TIA
> >>
> >> Graham
> >>
> >> _______________________________________________
> >> 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
> >
> >
> > _______________________________________________
> > 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
>
> _______________________________________________
> 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