Page 1 of 1

Adding Options to an option Menu

Posted: Fri Sep 15, 2023 9:26 pm
by trags3
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.

Re: Adding Options to an option Menu

Posted: Fri Sep 15, 2023 10:19 pm
by cpuandnet
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

Re: Adding Options to an option Menu

Posted: Fri Sep 15, 2023 10:57 pm
by dunbarx
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

Re: Adding Options to an option Menu

Posted: Sat Sep 16, 2023 1:18 am
by stam
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.