Adding Options to an option Menu

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
trags3
Posts: 418
Joined: Wed Apr 09, 2014 1:58 am
Location: Las Vegas, NV

Adding Options to an option Menu

Post by trags3 » Fri Sep 15, 2023 9:26 pm

HI I want the User to be able to Add an option menu item.
There are 2 options but in the future there may be additional choices required.
I want the user to be able to add options if required.
When the user selects an empty line I want them to be able to add a third choice that would then show up as a permanent choice.

Please see the attached screen shot.
Attachments
Screen Shot 2023-09-15 at 11.26.36 AM.jpg

cpuandnet
Posts: 32
Joined: Thu Jan 17, 2019 6:43 am

Re: Adding Options to an option Menu

Post by cpuandnet » Fri Sep 15, 2023 10:19 pm

Using a combobox might be easier then using a popup menu. The user can type in an unlisted value from the combobox and you can handle the closeField event in that case to ask the user if they want to add it to the option choices. I've attached an example stack of what i'm talking about. I hope this helps.

Tim
Attachments
example.zip
(1.5 KiB) Downloaded 49 times

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9670
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Adding Options to an option Menu

Post by dunbarx » Fri Sep 15, 2023 10:57 pm

Hi.

Not sure where this should start. First, do you know that to add menuItems to a menu-type button you simply set the text of that button to a return-delimited list?

Second, one can install a blank line in the contents of the button, as in:

Code: Select all

choice 1
choice 2

choice 3
And then in the button script, something like:

Code: Select all

on menuPick pItemName
   if pItemName = "" then --empty line selected
      ask "Enter new choice"
      put it into line (the menuHistory of me) of me --the menuHistory is the selected line
   end if
end menuPick
Is this a start?

Craig

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Adding Options to an option Menu

Post by stam » Sat Sep 16, 2023 1:18 am

trags3 wrote:
Fri Sep 15, 2023 9:26 pm
HI I want the User to be able to Add an option menu item.
There are 2 options but in the future there may be additional choices required.
I want the user to be able to add options if required.
When the user selects an empty line I want them to be able to add a third choice that would then show up as a permanent choice.
You can manage the choices as a return delimited list (eg stored in a text file, database, custom property or whatever, just some text with 1 choice per line).

Setting the text of the option menu button sets the available options
Setting its label sets what is displayed.

You can therefore just manage this all in code.
HTH
S.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”