Dropdown Button

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
warrenk
Posts: 110
Joined: Sun Sep 21, 2008 5:39 am

Dropdown Button

Post by warrenk » Sat Nov 22, 2008 8:28 pm

I have a dropdown button with all 50 states (ie. Minnesota, Wisconsin, etc). How to I point to the correct state in the dropdown button based on the value of a variable where the variable has a specific state in it.

Warren

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Sat Nov 22, 2008 9:07 pm

Hi warrenk, I had a brief scout around the Dictionary but personally couldn't find a way to get a particular line of a dropdown menu to highlight itself using mouseDown (rather than MenuPick, as stuff within a MenuPick handler obviously wouldn't happen until you picked (clicked) a menu item, which is not what you want to do); maybe there is a way somewhere...

Another way that seems to promise more success would be to make your menu from a stack menu. Haven't investigated stack menus much but seem to remember Mark having a neat stack on his RevOnline page, if you're unfamiliar with this. This way you'll have an easier time telling a particular button (menu item) to hilight based on your variable at the time...haven't done any tests on that but fairly certain that'll be the direction to go...

:)

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Sat Nov 22, 2008 9:31 pm

How about

Code: Select all

set the label of button "btnDropDown" to (tVariable)
does that work? If not, what circumstances are you trying to do this in?

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Sat Nov 22, 2008 10:23 pm

Or (just had another thought): if I understand you correctly, when the user clicks on the pulldown menu, you want the menu list to appear as usual but a particular menu item already highlighted for them, based on your variable. Presumably then, the user goes to that highighted menu item to select it.

If this is correct, could I suggest that you don't need a pullDown menu at all? Why not put your variable name into a button or a field made to look like a button; or into a field with a small "go" button beside it; they'd be a bit more scripting involved, telling the field or button what to do when it's pressed, depending on which variable is in use, but this way, at least, would be more straightforward and less "work" for your user.

:)

warrenk
Posts: 110
Joined: Sun Sep 21, 2008 5:39 am

Post by warrenk » Fri Nov 28, 2008 1:40 am

Thanks everyone for the advice. I decided to use the dropdown to load a field. If the user wanted to change the value in the field, they just had to select a new value from the dropdown.

Warren

Post Reply