Can any object do this...
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Can any object do this...
I want to have a drop-down menu in which
the user can type his required filename prefix
for a particular project and be able to choose it
later without typing it in again.
Tried the standard objects and seem to only
be able to add items programmatically.
Could do of course but simpler if the user
can type in a field.
Any ideas?
the user can type his required filename prefix
for a particular project and be able to choose it
later without typing it in again.
Tried the standard objects and seem to only
be able to add items programmatically.
Could do of course but simpler if the user
can type in a field.
Any ideas?
Life is just a bowl of cherries.
Can any object do this...
The comboBox seems to be the answer.
Will have to use an input field and a button
to add the item to the comboBox.
And is there a system variable which shows how
many items are already in the comboBox so that
a new one can be added in the next empty slot?
In the 2.8.1 docs under "comboBox" is the following:
"Using the text box at the top of the combo box, the
user can specify a state that is not in the menu's list
of states".
This statement isn't true for any comboBox I've used.
Have I missed something?
Will have to use an input field and a button
to add the item to the comboBox.
And is there a system variable which shows how
many items are already in the comboBox so that
a new one can be added in the next empty slot?
In the 2.8.1 docs under "comboBox" is the following:
"Using the text box at the top of the combo box, the
user can specify a state that is not in the menu's list
of states".
This statement isn't true for any comboBox I've used.
Have I missed something?
Life is just a bowl of cherries.
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
When you're using a combobox (not an optionmenu, where you don't have a real textbox to type into anyway), the user can type just about anything, unless you script to prevent this from happening.
As for adding new items at the end, you can just
Hope this helped,
Jan Schenkel.
As for adding new items at the end, you can just
Code: Select all
put return & theNewItem after button "MyMenuButton"
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
Can any object do this...
Jan
Had some fun with comboBox.
Only one item can be typed in direct.
Any further items have to be put in
programmatically.
When the "second" item is put in the
first disappears.
So they all have to be put in by program
which means that I have to test before
adding the "cr" else there's a blank first
entry.
When it comes to removing entries
it seems that if I loop through them
only every second one is delete.
Don't expect users will want to do that
but would like to know how to reference
the visible one and delete it and no others.
----Also would like to know if there's a way to put
the cursor in the input field without figuring it
out from co-ordinates. Something along the
lines of "to field fldSomeName" would be
ideal!
----Found "focus" so "focus on field fldSomeName"
does the trick.
Had some fun with comboBox.
Only one item can be typed in direct.
Any further items have to be put in
programmatically.
When the "second" item is put in the
first disappears.
So they all have to be put in by program
which means that I have to test before
adding the "cr" else there's a blank first
entry.
When it comes to removing entries
it seems that if I loop through them
only every second one is delete.
Don't expect users will want to do that
but would like to know how to reference
the visible one and delete it and no others.
----Also would like to know if there's a way to put
the cursor in the input field without figuring it
out from co-ordinates. Something along the
lines of "to field fldSomeName" would be
ideal!
----Found "focus" so "focus on field fldSomeName"
does the trick.
Life is just a bowl of cherries.
Re: Can any object do this...
This is probably because you are looping from the start of the list and incrementing the pointer. When you delete the first item, then item 2 becomes item one, but your pointer is still set as 2. So the next delete will be the (current) item 2, which used to be item 3 until item 1 got deleted, and so on.bjb007 wrote:When it comes to removing entries
it seems that if I loop through them
only every second one is delete.
If you start the loop at the end and go down to the beginning with your pointer then the problem should be avoided.
Re: Can any object do this...
You've probably already worked out what you can do and have an acceptable solution, but you don't need to put an input field and button to program the combo box. The following script in the combo box itself seems to work for me.bjb007 wrote:Had some fun with comboBox.
Only one item can be typed in direct.
Any further items have to be put in
programmatically.
When the "second" item is put in the
first disappears.
So they all have to be put in by program
which means that I have to test before
adding the "cr" else there's a blank first
entry.
Code: Select all
on closeField
local tText, tLabel
put the text of me into tText
put the label of me into tLabel
put cr & tLabel after tText
if line 1 of tText is empty then delete line 1 of tText
sort tText --optional
set the text of me to tText
set the label of me to tLabel
end closeField
Can any object do this...
Thanks SparkOut.
That works a treat.
I wouldn't have figured that out
in a month of Sundays.
That works a treat.
I wouldn't have figured that out
in a month of Sundays.
Life is just a bowl of cherries.
Glad it helped.
There is one caveat though - which is that if after entering a new item in the combo-box, the user clicks a button which does not have the traversalOn property set (ie the "Focus with keyboard" box is not checked, so that a user can click it with the mouse, but tabbing via the keyboard will not activate it) then the closeField event is not sent to the combo-box until after the button handlers have been executed and the focus goes to some other control. In this case it shouldn't matter too much, but it's worth being aware that the closeField event has that particular quirk.
You should also test that the string typed does not already match an item in the list too, in case the user was too lazy to click the button and find it was already there.
There is one caveat though - which is that if after entering a new item in the combo-box, the user clicks a button which does not have the traversalOn property set (ie the "Focus with keyboard" box is not checked, so that a user can click it with the mouse, but tabbing via the keyboard will not activate it) then the closeField event is not sent to the combo-box until after the button handlers have been executed and the focus goes to some other control. In this case it shouldn't matter too much, but it's worth being aware that the closeField event has that particular quirk.
You should also test that the string typed does not already match an item in the list too, in case the user was too lazy to click the button and find it was already there.