Grouped Pulldown Menus (finding message & property names)

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
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Grouped Pulldown Menus (finding message & property names)

Post by townsend »

I'm got 3 Pulldown Menu Buttons Grouped together.
Rather than place code in each button, I want to place all my code in the Group's Script area.

This code,

Code: Select all

on mouseUp
     local opp
     put the text of the target into opp
     answer opp
end mouseUp
produces this result.
143 pulldown menu example.jpeg
What can I use to capture a single choice, instead of all choices?
Last edited by townsend on Sat Nov 12, 2011 11:51 pm, edited 2 times in total.
mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3582
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Grouped Pulldown Menus

Post by mwieder »

Code: Select all

    on menuPick pChosen
         answer pChosen
    end menuPick
bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4219
Joined: Sun Jan 07, 2007 9:12 pm

Re: Grouped Pulldown Menus

Post by bn »

Hi,
What can I use to capture a single choice, instead of all choices?
try:

Code: Select all

on mouseUp
        local opp
        put the selectedText of the target into opp
        answer opp
end mouseUp
Kind regards

Bernd
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: Grouped Pulldown Menus

Post by townsend »

Thanks Bernd-- That worked!
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: Grouped Pulldown Menus

Post by townsend »

Oh yeah! Mark-- your solution worked too.

Code: Select all

  on menuPick pChosen
         answer pChosen
    end menuPick
Actually-- that menuPick message (event) is ideal for what I am trying to do.

I was going to ask you, is there any documentation or place, where I could have looked up,
"ALL messages available to Group objects?" Where I might have discovered this myself.
Then I remembered the Message Watcher, under Development, on the Menu Bar.
bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4219
Joined: Sun Jan 07, 2007 9:12 pm

Re: Grouped Pulldown Menus

Post by bn »

Hi townsend,

I think Mark's solution (menuPick) is the more logical choice
"ALL messages available to Group objects?" Where I might have discovered this myself.
When you open the dictionary and select "group" in the left part under "objects" (expand if necessary) and than select "Type" for sorting you have all properties and messages concerning groups sorted. This works of course for all categories in the dictionary.

But actually you would not have found MenuPick since it is a message that is send by menus and is passed up the message path. Since the group is in the message path you can script for the menuPick message of all menus in that group.

Kind regards

Bernd
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: Grouped Pulldown Menus

Post by townsend »

I didn't think of that-- excellent point there Bernd.

And, sorting the entire Dictionary by Type gives you a list of all possible Messages.
(It's really not that long.) Which is a good resource to know about.
bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4219
Joined: Sun Jan 07, 2007 9:12 pm

Re: Grouped Pulldown Menus

Post by bn »

Hi townsend,

while we are at it. Sometimes I forget the property names of objects. Than I make up a stack with a button a field and the object type I am interested in. E.g. graphic

in the button

Code: Select all

on mouseUp
   put the properties of grc 1 into tArray
   combine tArray by return and tab
   filter tArray without empty
   put tArray into field 1
end mouseUp
it lists the properties (or most so I was told) of a graphic and the actual values for the particular graphic.

Kind regards

Bernd
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: Grouped Pulldown Menus

Post by townsend »

Interesting-- I think that "grc" needs to be "group".
Thanks-- I just added this to my code clips library.

This code,

Code: Select all

on mouseUp
     put the properties of group "mygroup" into tArray
     combine tArray by return and tab
     filter tArray without empty
     put tArray into fld "report"
end mouseUp
Produced this report,
145 properties.jpeg
bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4219
Joined: Sun Jan 07, 2007 9:12 pm

Re: Grouped Pulldown Menus

Post by bn »

Hi,

graphic was supposed to be just an example. You can do this for all types of objects.

Kind regards

Bernd
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: Grouped Pulldown Menus

Post by townsend »

Yes-- of course-- this code, when placed in a button can collect ALL the properties of any object.
THEN using a Set Statement, any of those properties can be modified. (!!)

This thread turned out to be nice little lesson.
All these tips save time.
Post Reply