dead click functions
J. Landman Gay
jacque at hyperactivesw.com
Sat Jun 6 22:15:26 EDT 2009
DunbarX at aol.com wrote:
> One button, one field with text in it. I click the button and then click in
> the field.
>
> Button script:
>
> on mouseUp
> set cursor to cross
> wait until the mouseClick
> put the clicktext
> end mouseUp
>
> In HC, one gets data from this and similar text/chunk
> (clickText,clickChunk) functions, even in unlocked fields.
>
> In Rev, one does not; empty is returned. The functions all work if the
> handler is in the field script though. Something I am missing in the way targets
> operate in Rev?
>
> However, the clickLoc (and similar types like clickV and clickH) works from
> the button. Why?
The mouseclick function is ephemeral and not always reliable. In HC, the
engine kept a queue of events and always knew when three events happened
sequentially (mouse down, still down, up). MetaCard used to do this
early on and the mouseclick worked about the same way as HC. But
eventually this got in the way of other mouse messages as the language
matured, and Scott Raney started a brief discussion on the MC list about
how to resolve the problem. The upshoot was that the old behavior was
dropped and instead, the engine only checks for a mouseclick (and other
mouse states) at the exact moment the script asks for it. If the
necessary events aren't present in the queue at that precise moment,
nothing is returned.
This is also why checking for a mouseclick inside a repeat loop is a bad
idea, especially in long loops. There's a chance that the loop won't
notice a mouseclick has happened.
There are better ways in Rev to get the same info that the mouse
messages used to get in HC. In this case, a selectionChanged message
would probably do it. On selectionchanged, check the selectedtext, or
the selectedChunk, or the clicktext, or whatever you need to know.
My web page on mouse polling explains some related concepts:
<http://www.hyperactivesw.com/polling.html>.
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list