How to replace all menuItems of an option menu button?

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
sritcp
Posts: 431
Joined: Tue Jun 05, 2012 5:38 pm

How to replace all menuItems of an option menu button?

Post by sritcp » Sat Oct 06, 2012 8:28 pm

I don't know how to reference the container of all menuItems.

Code: Select all

Put menuItem i of button "Choose Name"
returns the particular menuItem.
But, if I want to replace all the menuItems with the contents of a field,

Code: Select all

put field "newMenuItems" into menuItems of button "Choose Name"
doesn't work. The dictionary says that menuItem is a keyword, not a property.

How do I reference the collection of menuItems, so I can deal with them together instead of using a repeat loop?

Thanks,
Sri.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: How to replace all menuItems of an option menu button?

Post by jmburnod » Sat Oct 06, 2012 8:57 pm

Hi Sri.

Code: Select all

set the text of btn "Choose Name" to the text of field "newMenuItems" 
Best regards
Jean-Marc
https://alternatic.ch

sritcp
Posts: 431
Joined: Tue Jun 05, 2012 5:38 pm

Re: How to replace all menuItems of an option menu button?

Post by sritcp » Sat Oct 06, 2012 9:44 pm

Thanks, Jean-Marc!

Sri.

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

Re: How to replace all menuItems of an option menu button?

Post by dunbarx » Sat Oct 06, 2012 9:57 pm

What Jean-Marc said.

He populated the button by setting its text property, and that is fine. You can also do it the other way, by simply considering the button as a container, which it is, and:

put yourMenuItems into btn "yourButton".

Craig Newman

sritcp
Posts: 431
Joined: Tue Jun 05, 2012 5:38 pm

Re: How to replace all menuItems of an option menu button?

Post by sritcp » Sat Oct 06, 2012 10:02 pm

Amazing! I was trying all kinds of complex things!
If all else fails, try the obvious!

Thanks, Craig!

Sri.

Post Reply