Page 1 of 1

popping up a menu choice

Posted: Tue Jul 31, 2012 2:35 pm
by Newbie4
How do I pop-up a menu choice in another handler?
What I want to do is on a button press is to do some calculations then pop-up a menu choice for the user to select from.

I tried putting a pop up button next to my other button and setting it not visible. Then when the user presses the other button, I do my calculations, and set my pop-up button to visible. The user never gets to make a choice from the pop-up button. It flashes briefly then goes back to my code.

Code: Select all

on mouseUp

   ...do some calcs

   global userAmount
   set the visible of button "amountMenu" to true
   (the button puts the user's choice into the global userAmount)
   set the visible of button "amountMenu" to false
   ... more calcs

end mouseUp
The problem is that the pop-up button does not wait for the user to select a choice. How do I get it to pause and wait for the user to make his/her choice?

Or should I be using some other construct to be doing this?

Thank you

Re: popping up a menu choice

Posted: Tue Jul 31, 2012 2:50 pm
by Klaus
Hi Newbie4,

any reason to NOT use a (real) Popup Menu type button? 8)

Do this:
1. Create a new "popup menu" button from the tools palette, name it e.g. "mypop"
2. Script it to do the right thing
3. Hide this button!
4. Add this to the button that should let the popup pop up :D

Code: Select all

on mousedown tNumber
  ## Right-click to popup
  if tNumber = 3 then
    ## do your calcultations here...
    popup btn "mypop" at the mouseloc
  end if
end mousedown
But maybe I do not understand what you want to achieve...


Best

Klaus

Re: popping up a menu choice

Posted: Tue Jul 31, 2012 4:48 pm
by dunbarx
You can just do this:

click at the loc of btn "yourPopUpButton"

The button's contents will appear, just as if you clicked on it, and you can then select any of its menuItems. The menuPick handler in that button will run. This works with all styles of pop-up type buttons, but note that if you use a comboBox style, you must click at the right side of that button to invoke the menuItems:

click at the right of btn "yourComboBox" - 3 & "," & item 2 of the loc of btn "yourComboBox"


Craig Newman

Re: popping up a menu choice

Posted: Tue Jul 31, 2012 5:00 pm
by Newbie4
Thank you, the popup command was exactly what I was looking for to make it visible