contextual menu cursor image

Richard Gaskin ambassador at fourthworld.com
Thu May 10 10:47:48 EDT 2007


Stephen Barncard wrote:

 >>If we had a message notifying us when the Control key is down
 >>without another key or a mouseDown I'd probably start using it.  I
 >>guess in the meantime we'd have to poll for that, no?
 >>
 >>Maybe Apple's onto something in blowing that off that part of their
 >>own spec. ;)
 >
 > actually it can be done without polling, this is how I'm controlling
 > the cursor, with a script in a locked field. works for my particular
 > case....ymmv...
...
 >
 > ON mouseWithin
 >           cursorHandler
 > END mouseWithin
...

While you're not doing the polling yourself, I believe all messages tied 
to the idleRate (mouseWithin, mouseStillDown, idle, maybe one or two 
others) are accomplished by the engine doing the polling.

The polling messages related to mouse actions (mouseWithin, 
mouseStillDown) can be especially problematic as they can't be used in 
libraries, or even card or stack scripts:  to minimize the impact of the 
engine's polling on the rest of the system, as noted in the docs those 
messages are only sent  to a control if the control has its own handler 
for them.


I just double-checked this, with a stack that has two buttons.  One 
button has this script:

on mouseWithin
   put the ticks && the target
   pass mouseWithin
end mouseWithin

The handler is also in the card script, and the second button has no 
script at all.

When mousing over the two buttons, I get the expected string in the 
Message Box only when the mouse is over the button that has its own 
mouseWithin handler, but not in the button whose script is empty.

With other non-polling messages, of course the message would pass 
through to the card and be handled there.


That said, the engine does its polling pretty efficiently, so in spite 
of whatever caveats folks might have for the mouseStillDown and 
mouseWithin messages, there's probably no noticeable penalty for using them.

But if you want to generalize the mouseWithin handling in a stack, 
library, or backScript, you'd have to replicate the mouseWithin handler 
in each control where you want that behavior triggered.


For the long term it might be helpful to add a BZ request for a message 
to be sent when the Control key is down, regardless of whether it has 
another key pressed with it.  There are tradeoffs for that, though, and 
maybe a new message is what's needed.

I have a similar request for mouseStillDown:
<http://quality.runrev.com/qacenter/show_bug.cgi?id=1832>

For checking whether the Control key is down, my hunch is that the OS X 
API already has a message available that could be tapped into, so 
tapping into that within Rev should be relatively straightforward once 
we figure out what that message should be called.  ControlKeyDown would 
seem logical enough, but it would be problematic to send it without 
another key since so many scripts currently expect the message to be 
sent only when two or more keys are pressed.

-- 
  Richard Gaskin
  Fourth World Media Corporation
  ___________________________________________________________
  Ambassador at FourthWorld.com       http://www.FourthWorld.com




More information about the use-livecode mailing list