Forums › Forums › SIMPOL Programming › combobox onselectionchange problem
- This topic has 2 replies, 2 voices, and was last updated 14 years, 5 months ago by Michael.
- AuthorPosts
- December 7, 2009 at 9:20 am #54Jim LockerMember
This doesn’t seem to be working properly. When I first build a form, the event handler for all combo boxes gets called as soon as I populate the combo box, even though there has been no user selection. Further, when I first click on the combobox to make a selection, the handler is immediately called, and is called repeatedly while I scroll through the drop-down list of choices. However, when I finally click on my choice, it appears in the textbox for the combobox, but the handler is NOT called. I am also invoking the same handler for onlostfocus, so the event I want to have happen doesn’t actually happen until I click away from the combobox. This isn’t a showstopper right now, but will be when I go to release this thing. What is happening here?
December 7, 2009 at 9:34 am #1432Jim LockerMemberAnd, no sooner did I post this, then I found the answer.
I am using the dropedit form of the box, permitting the user to enter his
own text in the control.I was just directly accessing the text of the control using the fc.text
property, but I needed to be using the gettext() method instead.Apparently, when I make a selection, the text field still contains the old
text when the onselectionchange event is called. This prevents my form
updates since my event handler tests to make sure a change was actually
made. This is necessary because it is getting called over and over while
the user plays with the combobox.December 8, 2009 at 7:31 pm #1476MichaelKeymasterJim wrote:
> And, no sooner did I post this, then I found the answer.
>
> I am using the dropedit form of the box, permitting the user to enter
> his own text in the control.
>
> I was just directly accessing the text of the control using the
> fc.text property, but I needed to be using the gettext() method
> instead.
>
> Apparently, when I make a selection, the text field still contains
> the old text when the onselectionchange event is called. This
> prevents my form updates since my event handler tests to make sure a
> change was actually made. This is necessary because it is getting
> called over and over while the user plays with the combobox.There is definitely issues when dealing with editable comboboxes.
Basically, when using the "droplist" style, always use the
..getselected() method and the .select() method. When using the
"dropedit" style, you should differ between the functions that handle
the onchange and the onselection change. There is no guarantee that any
value in the textbox will match the current selection in the list. Makes
sense, since the user can put anything in the edit control, and it
doesn't have to be in the list. You could choose to add it and select it
if not present in the onlostfocus event.Ciao, Neil
- AuthorPosts
- You must be logged in to reply to this topic.