- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Question on ComboBox
I can create options for Combo Box with pop up tips using something like that (found this experimentally):
Names Default To Here( 1 );
list = {"One" ("This is One"), "Two" ("This is two")};
New Window( "Example",
cb = Combo Box(
list,
selection = cb << GetSelected();
Print( selection );
)
);
But then when I look at the selection - it only has "One" or "Two" as a result of << Get Selected.
Two questions:
1. What kind of data structure is the list above? It's a list of what? list[1] gives me exactly "One"("This is one") - is it a string, or what is it?
2. How do I work with this list, let's say if it was a normal list like {"One", "Two"}, I would put in a script part something like this:
if(
selection == list[1], doThis,
selection==list[2], doThat
);
But how do I do it when I have pop up tips included?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Question on ComboBox
There may be a Community member that has a better way of dealing with the Combo Box list structure, but the only way that I figured out how to deal with it is by making the whole list into a string, and then parsing it out with the Word Function
Names Default To Here( 1 );
list = {"One" ("This is One"), "Two" ("This is two")};
tipstr1 = word(4,char(list),"\!"");
which returns
"This is One"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Question on ComboBox
The scripting index shows that structure for tip strings in the combo box. I never realized you could include tooltips with a combobox - neat feature.
You can create the "real" list from the list with tooltips. Also I'd refrain from using "list" as a variable, as it is a function in JSL.
Names Default To Here( 1 );
list_tips = {"One" ("This is One"), "Two" ("This is two")};
New Window( "Example",
cb = Combo Box(
list_tips,
selection = cb << GetSelected();
Print( selection );
)
);
mylist = {};
for (i = 1, i <= nitems(list_tips), i++,
pq = contains(list_tips[i], "(\!"");
mylist[i] = substr(list_tips[i], 1, pq - 1);
);
if (
selection == mylist[1], doThis,
selection == mylist[2], doThat
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Question on ComboBox
In your example, List is a list that has 2 entries.
- "One" ("This is One")
- "Two" ("This is two")
The Combo box divides each list entry into Item and tipstr.
selection = cb << GetSelected();
returns only the item
If you want the tipstr returned, you need to use
tipstr = (cb << get items)[cb << Get];
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Question on ComboBox
Thanks, Jim.
Still not very clear - each entry is a string? Where quotes escaped?
And if I want to use the same list in an if statement in a script for the combobox, I would have to extract the item itself? Like:
if(
selection == Word(1, list[1], "\!"()"), doThis,
selection==Word(1, list[2], "\!"()"), doThat
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Question on ComboBox
There may be a Community member that has a better way of dealing with the Combo Box list structure, but the only way that I figured out how to deal with it is by making the whole list into a string, and then parsing it out with the Word Function
Names Default To Here( 1 );
list = {"One" ("This is One"), "Two" ("This is two")};
tipstr1 = word(4,char(list),"\!"");
which returns
"This is One"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Question on ComboBox
The scripting index shows that structure for tip strings in the combo box. I never realized you could include tooltips with a combobox - neat feature.
You can create the "real" list from the list with tooltips. Also I'd refrain from using "list" as a variable, as it is a function in JSL.
Names Default To Here( 1 );
list_tips = {"One" ("This is One"), "Two" ("This is two")};
New Window( "Example",
cb = Combo Box(
list_tips,
selection = cb << GetSelected();
Print( selection );
)
);
mylist = {};
for (i = 1, i <= nitems(list_tips), i++,
pq = contains(list_tips[i], "(\!"");
mylist[i] = substr(list_tips[i], 1, pq - 1);
);
if (
selection == mylist[1], doThis,
selection == mylist[2], doThat
);