Skip to content

combobox onselectionchange problem

Forums Forums SIMPOL Programming combobox onselectionchange problem

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #54
    Jim Locker
    Member

    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?

    #1432
    Jim Locker
    Member

    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.

    #1476
    Michael
    Keymaster

    Jim 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

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.