PopUp to TextLabel?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
PopUp to TextLabel?
I am a longtime programmer who has been "out of the game" and am trying to return to the hobby after a long absence. I need a little nudge here.
I am just trying to get restarted with how LC works, I have a lot settled but got stuck on this problem, I am hoping someone can either provide a simple example stack, or walk me through it. Could be a simple one stack example!
How do I get the data/selection from an Option Menu to a text Label Field via a short script? My goal is to eventually use a "centralized script" available from a stack to collect the various pieces of data from several Option Menus and spill the results into a Label Field for display of the calculations. Simple, I just cannot remember/find how to do that.
So, the Option Menu would get a value from its list of options (I understand how to make those custom selections) and pass it to a script that would perform some simple manipulations (I will be using "numerical data", I understand how to convert that from text to the integer equivalent) and then putting the results into a Label Field on the same stack.
Help is appreciated. I used to be able to do this sort of thing in other development environments. I understand methods and handlers and objects, etc. The syntax is a little different here and I am stumbling over remembered data. I thought I would not have this problem, but life is funny that way! To the best of my knowledge LC is the way I will be going in the future, so might as well make the transition! Strictly a hobbyist - my professional developer days are behind me.
I am just trying to get restarted with how LC works, I have a lot settled but got stuck on this problem, I am hoping someone can either provide a simple example stack, or walk me through it. Could be a simple one stack example!
How do I get the data/selection from an Option Menu to a text Label Field via a short script? My goal is to eventually use a "centralized script" available from a stack to collect the various pieces of data from several Option Menus and spill the results into a Label Field for display of the calculations. Simple, I just cannot remember/find how to do that.
So, the Option Menu would get a value from its list of options (I understand how to make those custom selections) and pass it to a script that would perform some simple manipulations (I will be using "numerical data", I understand how to convert that from text to the integer equivalent) and then putting the results into a Label Field on the same stack.
Help is appreciated. I used to be able to do this sort of thing in other development environments. I understand methods and handlers and objects, etc. The syntax is a little different here and I am stumbling over remembered data. I thought I would not have this problem, but life is funny that way! To the best of my knowledge LC is the way I will be going in the future, so might as well make the transition! Strictly a hobbyist - my professional developer days are behind me.
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: PopUp to TextLabel?
Hi,
If I understand correctly what you want to do i think "label" is the magic word.
something like that:
I noticed that the value doesn't work with a string that contains a space char.
The value of "choice 1" return an error
Best regards
Jean-Marc
If I understand correctly what you want to do i think "label" is the magic word.
something like that:
Code: Select all
...
put empty into tAllLabels
put "mybtnoption1,mybtnoption2" into tAllOptions
repeat for each item tOneOption in tAllOptions
put (the value of the label of btn tOneOption) & cr after tAllLabels
end repeat
put tAllLabels
...
The value of "choice 1" return an error
Best regards
Jean-Marc
https://alternatic.ch
Re: PopUp to TextLabel?
Taking you literally, it could be something as simple as this - Mind you, there are only 2 controls there, I didn't name anything, but if your going more than that I would make it more like
Code: Select all
on menuPick pItemName
put pItemName into field "MySnazzyField"
end menuPick
Code: Select all
put pItemName into field "MySnazzyField" of card "myCard" of stack "mystack"
Re: PopUp to TextLabel?
Thanks for the replies. I have managed to injure my left eye and so am not as nimble with the keyboard as I like to be - I am healing and will get back to this as soon as I am able to focus properly! Sorry for radio silence!
(Hey, RunRev, please stop changing my password! Thanks.)
(Hey, RunRev, please stop changing my password! Thanks.)
Re: PopUp to TextLabel?
Hope your eye gets better soon, if possible. We will still be here when your ready to go
Re: PopUp to TextLabel?
Thanks for the well-wish. I am able to read large high-contrast text now!
Anyway, I started digging around and have come up with some things that are working and some things that are not.
I have a stack with 4 controls on it - A Choice Menu, a Label Field to display its contents a PopUp Menu and a Label Field2 to display its contents. The following script is in the script for the card itself:
on mouseUp
Set the text of field "Label Field" to the Label of button "ChoiceButton"
Set the text of field "Label Field2" to the Text of button "PopUp Menu"
end mouseUp
The first Set works perfectly.
The second Set just makes Lebel Field2 blank. The PopUp Menu is labeled "Pick One" and the text is:
"1
2
3"
So, my questions:
How do I "capture" the SELECTION of the PopUp Menu? For now I am happy to just put it into the label.
Where can I read about how a PopUp Menu works? I cannot find any discussion of examples in the Beginners Guide OR Users Guide OR Resources OR Dictionary. Is there a guide for the controls?
How are people using the Dictionary? There is no search function that I can find. I cannot locate anything about the UI elements.
Is written documentation dead?
Anyway, I started digging around and have come up with some things that are working and some things that are not.
I have a stack with 4 controls on it - A Choice Menu, a Label Field to display its contents a PopUp Menu and a Label Field2 to display its contents. The following script is in the script for the card itself:
on mouseUp
Set the text of field "Label Field" to the Label of button "ChoiceButton"
Set the text of field "Label Field2" to the Text of button "PopUp Menu"
end mouseUp
The first Set works perfectly.
The second Set just makes Lebel Field2 blank. The PopUp Menu is labeled "Pick One" and the text is:
"1
2
3"
So, my questions:
How do I "capture" the SELECTION of the PopUp Menu? For now I am happy to just put it into the label.
Where can I read about how a PopUp Menu works? I cannot find any discussion of examples in the Beginners Guide OR Users Guide OR Resources OR Dictionary. Is there a guide for the controls?
How are people using the Dictionary? There is no search function that I can find. I cannot locate anything about the UI elements.
Is written documentation dead?
Re: PopUp to TextLabel?
As far as this question goes, the search box is the one highlighted, the guide (which is one of the few things I think actually improved in the newer versions) is located where the arrow is pointing. While I use the dictionary a lot, I use this version of Lc far less. When I do use it, I tend to use Bernd's "Tiny dictionary" plug in, it can be found in the user share section.
Well, to 'capture' it, you would do something like I did in the first example, although there are many many other ways to do it.
Somethings though never (seem to) change though, and manipulating text is one of those things Lc really makes pretty easy. The question I have at this point is, did you try either suggestion by Jean-Marc or myself? His suggestion works based on the label of the button, mine works by which menu item you selected, and while his is more readily located just about anywhere, either can be made to work that way (my handler is directly in the menu buttons script).
In any case, we'll move on to your main question, the results you got -
Code: Select all
on mouseUp
Set the text of field "Label Field" to the Label of button "ChoiceButton"
Set the text of field "Label Field2" to the Text of button "PopUp Menu"
end mouseUp
Re: PopUp to TextLabel?
Yes I have "explored" the lessons posted above, all very helpful and I thank you all for that. I think I have the Option Menu figured out.
My latest questions are about the PopUp Menu - I should not have drifted the conversation. Used on what I have seen, I think the Option Menu is what I am looking for anyway.
I was looking at the "Guide" part of the Dictionary. Switching to the API part brought out the search feature! Lots of new toys and paradigms...
My latest questions are about the PopUp Menu - I should not have drifted the conversation. Used on what I have seen, I think the Option Menu is what I am looking for anyway.
I was looking at the "Guide" part of the Dictionary. Switching to the API part brought out the search feature! Lots of new toys and paradigms...
Re: PopUp to TextLabel?
That is ok to do, often it will drift to like things, just mention what it is drifting too and everythings fine
Ah, a pop up menu! It is not much different than the option menu, but there is one important distinction and that is that the 'label' of it will not change unless you do so programmatically, i.e.
Re: PopUp to TextLabel?
Yeah, a bit different. I decided to go with the Option thing rather than the PupUp, same result just a different way of displaying things.
Thanks.
Just out of lingering curiosity, how do I get the selection of a PopUp Menu?
Thanks.
Just out of lingering curiosity, how do I get the selection of a PopUp Menu?
Re: PopUp to TextLabel?
Same as you see in the pic or the first block of code
Code: Select all
on menuPick pItemName
// pItemName is the selection in this handler
put pItemName into field "MySnazzyField"
end menuPick
Re: PopUp to TextLabel?
Selection. Got it! Thanks again.
All is well, now on to data grids...
All is well, now on to data grids...
Re: PopUp to TextLabel?
Only up to 6 and I know how to set one up and get data from the selected row...