Page 1 of 1
How to pick selection in a field?
Posted: Fri Nov 12, 2010 3:41 pm
by 22c304
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
Re: How to pick selection in a field?
Posted: Fri Nov 12, 2010 4:47 pm
by shaosean
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.
Code: Select all
on mouseUp
put the selectedText of field "list" -- displays the selected text in the message box
end mouseUp
Now if you want to use this in an "if" statement
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
You can also use a "switch" statement instead of an "if" statement
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?
Posted: Fri Nov 12, 2010 8:13 pm
by 22c304
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
Re: How to pick selection in a field?
Posted: Fri Nov 12, 2010 11:22 pm
by Mark
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
Re: How to pick selection in a field?
Posted: Sat Nov 13, 2010 2:18 am
by 22c304
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
Re: How to pick selection in a field?
Posted: Sat Nov 13, 2010 2:47 am
by BvG
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.
Re: How to pick selection in a field?
Posted: Sat Nov 13, 2010 3:52 am
by Bantymom
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