Menu items, hard-coded or references
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Menu items, hard-coded or references
Hi
Is it possible to populate the list of menu items by reference to fields or variables instead of hard-coded items ?
Is it possible to populate the list of menu items by reference to fields or variables instead of hard-coded items ?
Re: Menu items, hard-coded or references
Sorry, no idea what you mean, could you give an example?
Re: Menu items, hard-coded or references
Hi Klaus,
I need to populate a menu with years, to include the current year. As this will change, instead of hardcoding 2022 as a menu item, the menu item needs to reference a field or variable referring to the current year, or, as the current year changes, code is invoked to put the current year into the list of menu items. Is it possible ?
I need to populate a menu with years, to include the current year. As this will change, instead of hardcoding 2022 as a menu item, the menu item needs to reference a field or variable referring to the current year, or, as the current year changes, code is invoked to put the current year into the list of menu items. Is it possible ?
Re: Menu items, hard-coded or references
If I understand what you mean, know that the menu items of a button are just the contents of that button. So if you:
Those values will appear as three choices when you click there.
Craig
Code: Select all
put "A" & return & "B" & return & "C" into button "yourComboBox"
Craig
Re: Menu items, hard-coded or references
You can always update/fill the content of a menu button dynamically "on mousedown", if that helps.
Ah, Craig already showed you how to do this...
But still no idea what kind of menu you are trying to create "on the fly".
Could you give an example?
Ah, Craig already showed you how to do this...
But still no idea what kind of menu you are trying to create "on the fly".
Could you give an example?
Re: Menu items, hard-coded or references
Klaus.
That is TWO times I beat you by just minutes in the last week!!! You now only lead by 28,435 to 2
Craig
That is TWO times I beat you by just minutes in the last week!!! You now only lead by 28,435 to 2
Craig
Re: Menu items, hard-coded or references
THIS MUST STOP, Craig!
Maybe I'm just getting old...



Maybe I'm just getting old...
Re: Menu items, hard-coded or references
CAsba
Did you examine the handler in the "Click here" button of the stack I posted? It shows just that, loading the contents of a field into the "contents" of a button.
And as Klaus belatedly
mentioned, you can do that (very nicely, in fact) right at the menu button itself, on mouseDown. Do you see all that?
Craig
Did you examine the handler in the "Click here" button of the stack I posted? It shows just that, loading the contents of a field into the "contents" of a button.
And as Klaus belatedly

Craig
Re: Menu items, hard-coded or references
I just wanted to get to 8700.
Craig
Craig
-
- VIP Livecode Opensource Backer
- Posts: 10045
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Menu items, hard-coded or references
CAsba, the others here have handled your question well. I just want to add a small but hopefully inspiring insight:
The LiveCode IDE is written in LiveCode Script. Anything you see it do -- such as providing an interface for setting the text of menu items -- is something you can do in your own apps.
So when you using the IDE to do something you'd like to do in your own script, you can look at the property name shown in the Inspector, and look that property up in the LiveCode API Dictionary.
Also, to get an empowering overview of the scope of object properties and how to use them, the User Guide included in the install (see the Help menu) is worth a skim. Just a few minutes reviewing the scope of content there will tell you where to turn to learn most aspects of LiveCode as they come up in your work.
These forums are a great resource, the people there very helpful. And when you need an answer right away, those two resources -- the Dictionary and the User Guide -- can often get you going in just minutes.
The LiveCode IDE is written in LiveCode Script. Anything you see it do -- such as providing an interface for setting the text of menu items -- is something you can do in your own apps.
So when you using the IDE to do something you'd like to do in your own script, you can look at the property name shown in the Inspector, and look that property up in the LiveCode API Dictionary.
Also, to get an empowering overview of the scope of object properties and how to use them, the User Guide included in the install (see the Help menu) is worth a skim. Just a few minutes reviewing the scope of content there will tell you where to turn to learn most aspects of LiveCode as they come up in your work.
These forums are a great resource, the people there very helpful. And when you need an answer right away, those two resources -- the Dictionary and the User Guide -- can often get you going in just minutes.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Menu items, hard-coded or references
Hi
Thanks everyone for your replies, and Craig, the code snippet you provided was spot on, it solved my prob.
Once again,
thanks to all of you.
Thanks everyone for your replies, and Craig, the code snippet you provided was spot on, it solved my prob.
Once again,
thanks to all of you.
Re: Menu items, hard-coded or references
If you haven't changed it in preferences, you will see an explanation of the property instead of the LC name. To see what you should look up in the dictionary, hover the mouse over the name to see the actual property name.So when you using the IDE to do something you'd like to do in your own script, you can look at the property name shown in the Inspector, and look that property up in the LiveCode API Dictionary.
Do yourself a favor and change the inspector to show the real property name. That reverses the response so that hovering shows the description.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com