Help with pop-up menu/choice button, please.

Eric Chatonet eric.chatonet at sosmartsoftware.com
Fri Jul 29 17:12:24 EDT 2005


Hi Alex,

I did not followed exactly this thread but just some thoughts:

In my plugins I use often popup menus I treat as they were "normal"  
menus called by clicking on a "normal" button.
In the "normal" button script:

on mouseDown
   if the platform = "MacOs" then ShowPullDownMenu
end mouseDown
----------------------------------------------
on mouseUp
   if the platform <> "MacOS" then ShowPullDownMenu
end mouseUp
----------------------------------------------
on ShowPullDownMenu
   <statements> -- building the menu in a variable named tMenu
   put the bottomLeft of me into tLoc
   if the platform = "MacOS" then add 2 to item 2 of tLoc
   else subtract 2 from item 2 of tLoc
   put tMenu into btn <popup button name> -- the items I want
   popUp btn <popup button name> at tLoc
end ShowPullDownMenu

Note that the behaviour can't be the same for Mac and Win32.
You could adapt the ShowPullDownMenu handler in order to act  
accordingly to your context: ie display a menu or do another action.
Hope but don't know if this helps :-)

Le 29 juil. 05 à 19:56, Alex Tweedly a écrit :

> This cannot be as hard as I'm making it ..... so I'll follow the  
> excellent advice from the list of not struggling over a simple  
> issue for more than an hour and ask for help.    Though I am about  
> 4 hours late .... :-(
>
> Easy bit:
> I want to have a button, that acts like a pop-up button - i.e. when  
> I click on it, up pops a list of choices and I can select one - or  
> I can click outside the list of options and get a "cancel"  
> indication back.  When a choice is made, I do the appropriate action.
> This is what I get with a "pop-up menu" selected from the IDE's  
> tool palette.
>
> Hard part:
> Sometimes, there is only one valid choice; in that case, I'd like  
> to go ahead with the appropriate action immediately - don't present  
> a menu, just do the action.
>
> I can put in a handler for the mouseDown to the pop-up button - but  
> can't find a way to avoid it popping up.
>
> I tried putting in another button, and having its mouseDown take  
> the action - either just doing it, or sending mouseDown to the pop- 
> up button - but apparently; sending a mouseDown isn't enough to  
> trigger the pop-up.
>
> (I tried a large number of other things, but I'm not going to  
> embarrass myself by listing them all ....)
>




More information about the use-livecode mailing list