popup command cross-platform

Ken Ray kray at sonsothunder.com
Thu Mar 4 20:11:19 EST 2010




On 3/4/10 4:59 PM, "Jeff Massung" <massung at gmail.com> wrote:

> So, I'm seeing different functionality w/ the popup command on OS X and
> Win32, wondering if I should mark this as a bug, and also wondering if
> anyone has a work-around?
> 
> -- in a field's script
> on mouseUp
>    set the backgroundColor of me to "black"
>    popup btn "some menu"
>    set the backgroundColor of me to "white"
> end mouseUp
> 
> On Mac OS X this will set the backgruond color black, popup the menu, and
> wait for me to "cancel" the popup or click a menu item in it, and then set
> the background color back to white. On Win32 the field goes black -> white
> instantly and the popup is still there.
> 
> I much prefer the OS X implementation (given this single context and what I
> want to have happen), but I understand the advantages of the Win32
> implementation. So if it's a bug, I could care less which version was
> considered "correct" by RunRev, but them being different I consider
> incorrect behavior.

Well, I don't know if it's a *bug*, but it is certainly inconsistent. Oh,
and you should do this on mouseDown instead of mouseUp.
 
> That said, anyone have a workaround for me?

All I can suggest is what I ended up having to do... make sure that the
popup command was the last thing encountered in the mouseDown handler, and
then have the menuPick of the btn being popped handle what happens when they
release the mouse button. If you need to pass data between the button
calling the popup command and the button being popped, you can use custom
properties or globals, etc.

Example:

-- Main button
on mouseDown
  set the backgroundColor of me to "black"
  set the uCaller of btn "some menu" to (the long id of me)
  popup btn "some menu"
end mouseDown

-- btn "some menu"
on menuPick pItem
  -- do whatever you want to do
  set the backgroundColor of (the uCaller of me) to "white"
end menuPick

HTH,

Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/





More information about the use-livecode mailing list