how to set default item in combobox

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
shalu
Posts: 72
Joined: Fri Mar 20, 2015 1:05 pm

how to set default item in combobox

Post by shalu » Tue Aug 04, 2015 7:38 am

Hi,

I am beginner in live code, I am looking for the code of set the default item in combobox , eg: select, item1, item2, item3, if I select item 2 or 3 after performing it's task the it's automatically set to "select" option, is it possible :roll:

--
Thanks,
Shalu S
--
Thanks
Shalu S

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: how to set default item in combobox

Post by Klaus » Tue Aug 04, 2015 12:01 pm

Namaste Shalu,

not sure I understand, but maybe you just want to:
...
set the LABEL of btn "your combobox here" to "What the user will read in the button"
...
?

The label is just a string, so you can set it to whatever you want to.


Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: how to set default item in combobox

Post by dunbarx » Tue Aug 04, 2015 2:13 pm

Hi.

I like to use the "menuHistory" property, since it gives me the line number of the option menu. So if you have:

item 1
item 2
item 3
item 4

in the menu, and you:

Code: Select all

set the menuHistory of btn "yourOption" to 3
the third line will appear. This will, as Klaus points out, also set the label property to "item 3".

Craig Newman

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: how to set default item in combobox

Post by Klaus » Tue Aug 04, 2015 2:39 pm

Hi friends,

remember that setting the menuhistory will also "fire" a MENUPICK with that menuitem!
Maybe this is unwanted here :D


Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: how to set default item in combobox

Post by dunbarx » Tue Aug 04, 2015 7:46 pm

True.

Setting the label of an option button does not change the menuHistory, nor fire the "menuPick" message.

One may set the menuHistory (in the earlier example) to, say, 1, which will show "item 1", and the label will also be "item 1". But if you then set the label to "item 3", the menuHistory does not change; it stays at 1. Perhaps this is a feature, that you can have the label follow the menuHistory, but not the other way around. Perhaps it is anomalous behavior.

Craig

Post Reply