popping up a menu choice

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Newbie4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 332
Joined: Sun Apr 15, 2012 1:17 am
Contact:

popping up a menu choice

Post by Newbie4 » Tue Jul 31, 2012 2:35 pm

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
Cyril Pruszko
https://sites.google.com/a/pgcps.org/livecode/
https://sites.google.com/a/setonhs.org/app-and-game-workshop/home
https://learntolivecode.com/

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: popping up a menu choice

Post by Klaus » Tue Jul 31, 2012 2:50 pm

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10321
Joined: Wed May 06, 2009 2:28 pm

Re: popping up a menu choice

Post by dunbarx » Tue Jul 31, 2012 4:48 pm

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

Newbie4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 332
Joined: Sun Apr 15, 2012 1:17 am
Contact:

Re: popping up a menu choice

Post by Newbie4 » Tue Jul 31, 2012 5:00 pm

Thank you, the popup command was exactly what I was looking for to make it visible
Cyril Pruszko
https://sites.google.com/a/pgcps.org/livecode/
https://sites.google.com/a/setonhs.org/app-and-game-workshop/home
https://learntolivecode.com/

Post Reply