Pull Down Menu - Default Text

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
CoreySchroeder
Posts: 26
Joined: Mon Sep 14, 2015 4:31 am

Pull Down Menu - Default Text

Post by CoreySchroeder » Sat Oct 17, 2015 5:02 pm

Hey there,

I've got a couple of pull down menus -

I would like to set a default text that is not one of the menu items.
If the user selects a menu item, I would like to display that menu item in the label.
If the user clicks on the pull down menu, but doesnt end up selecting one of the menu items, I'd like the label of the menu to stay the default text.

For example -
COLORS
-Red
-Blue
-Yellow

The default text displayed on the pull down menu would be "COLORS"
If the user clicks the menu and selects an item (lets say Blue), I'd like to set the label of the pull down menu to "Blue"
if the user clicks the menu but doesnt select an item, I'd like to keep the text of "COLORS" upon exit.

Any thoughts?

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

Re: Pull Down Menu - Default Text

Post by dunbarx » Sun Oct 18, 2015 5:46 am

Hi.

These sorts of exercises are always fun, mainly because there are several ways to do them. Try this. Make a pulldown. In its script:

Code: Select all

on menuPick pItemName
   set the label of me to  "Colors"
   if pItemName <> the label of me then set the label of me to pItemName
end menuPick

on mouseDown
   lock screen
  set the label of me to "Colors"
end mouseDown
I tried to think of a way to keep it all in the "menuPick" handler without another message (mouseDown) being required, but could not, since no message at all (except mouseDown) is sent from a pulldown if the user clicks in it, and then releases the mouse within the button rect itself. This also makes the "previousTab" parameter useless. So it feels like a kluge, though it works fine.

Craig Newman

Post Reply