How to pick selection in a field?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
How to pick selection in a field?
Hello everyone ....
I must be missing something really simple.
I know I can do this with a button using label, however .....
I have a field defined that contains three values (1st, 2nd,3rd) in Contents
The field has a vertical scrollbar and scrolls/shows the three values properly. I want to write an if statement based on the current value of the field. How do i get the value of this field?
Thanks for any suggestions ..
Wes
I must be missing something really simple.
I know I can do this with a button using label, however .....
I have a field defined that contains three values (1st, 2nd,3rd) in Contents
The field has a vertical scrollbar and scrolls/shows the three values properly. I want to write an if statement based on the current value of the field. How do i get the value of this field?
Thanks for any suggestions ..
Wes
Re: How to pick selection in a field?
If you have a button and a list field named "list" you can place the following code in the button to get the selected text of the field.
Now if you want to use this in an "if" statement
You can also use a "switch" statement instead of an "if" statement
Code: Select all
on mouseUp
put the selectedText of field "list" -- displays the selected text in the message box
end mouseUp
Code: Select all
on mouseUp
if (the selectedText of field "list" = "1st") then
-- do first stuff
else if (the selectedText of field "list" = "2nd") then
-- do second stuff
else if (the selectedText of field "list" = "3rd") then
-- do third stuff
end if
end mouseUp
Code: Select all
on mouseUp
switch (the selectedText of field "list")
case "1st"
-- do first stuff
break -- this breaks out of the case; if this is missing it will do the statements in the next case
case "2nd"
-- do second stuff
break -- this breaks out of the case; if this is missing it will do the statements in the next case
case "3rd"
-- do third stuff
break -- this breaks out of the case; if this is missing it will do the statements in the next case
end switch
end mouseUp
Re: How to pick selection in a field?
Thanks for the reply......
I understand case and if, that is not a problem.
I was trying to use a text entry field with a scroll property, NOT a list field. Can you case a text entry field for the current value?
There is no selectedtext or insertion point
Thanks........
Wes
I understand case and if, that is not a problem.
I was trying to use a text entry field with a scroll property, NOT a list field. Can you case a text entry field for the current value?
There is no selectedtext or insertion point
Thanks........
Wes
Re: How to pick selection in a field?
Hi Wes,
Your problem is not: how do I get some value of some field in some way, but rather how do I design a useful and functional interface. What you are trying to accomplish doesn't make sense. Please, redesign your interface.
Kind regards,
Mark
Your problem is not: how do I get some value of some field in some way, but rather how do I design a useful and functional interface. What you are trying to accomplish doesn't make sense. Please, redesign your interface.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: How to pick selection in a field?
Mark
FYI I was not planning on using this in a interface. I used a button to accomplish wgat i needed. But i wanted to know how it could be done in runrev. I was curious how to do it. As in why can you make a text entry field have multiple values if you cannot case the current selection/option.
Your reply seemed more of a opinion than an answer.
Wes
FYI I was not planning on using this in a interface. I used a button to accomplish wgat i needed. But i wanted to know how it could be done in runrev. I was curious how to do it. As in why can you make a text entry field have multiple values if you cannot case the current selection/option.
Your reply seemed more of a opinion than an answer.
Wes
Re: How to pick selection in a field?
Maybe mark just didn't understand what you actually want to do. Actually, neither do I, but maybe reading the following entries in the dictionary is helpful for you:
selectedText
hilitedText
offset
lineoffset
select
also note that pressing a button does remove the focus from a field, and this means the selection is emptied. to prevent that, set the traversalOn of the button to false.
selectedText
hilitedText
offset
lineoffset
select
also note that pressing a button does remove the focus from a field, and this means the selection is emptied. to prevent that, set the traversalOn of the button to false.
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
Re: How to pick selection in a field?
I have been following this thread with interest and confusion. Do you have a bit of a stack to show upload (as a zip file)? Do you have, perhaps a screenshot of what it looks like?
Cheers,
Bantymom
Cheers,
Bantymom
2nd-grade Teacher, Poultry Fancier, Scottish Country Dancer
and Perpetual Beginner
and Perpetual Beginner