Opened 7 years ago

Last modified 6 years ago

#3901 new defect

validator doesn't work with wxBitmapComboBox

Reported by: blizzymadden Owned by:
Priority: normal Milestone:
Component: GUI-all Version:
Keywords: wxBitmapComboBox wxValidator Cc: blizzymadden, p_michalczyk
Blocked By: Blocking:
Patch: no

Description

If you hook up a wxGenericValidator (with a wxString in it) to a wxBitmapComboBox, the string never gets updated when you call TransferDataToWindow() and vice versa. Example:

wxBitmapComboBox* languageCombo = new wxBitmapComboBox(this, wxID_ANY, _T(""), wxDefaultPosition, wxSize(100, -1), choiceStrings, wxCB_DROPDOWN|wxCB_READONLY, wxGenericValidator(&m_langName));

No matter what "m_langName" is, the combobox is empty when it appears, and when you call TransferDataToWindow(), m_langName is emptied. If I swap in a regular wxComboBox into this code it works perfectly.

Change History (5)

comment:1 Changed 7 years ago by p_michalczyk

Please send some working code, then I will take a closer look at it.

comment:2 Changed 7 years ago by blizzymadden

Do you need the code for the entire dialog? Just drop this into any dialog's creation code and note that this combobox is empty when it appears. And when you call TransferDataFromWindow() from the OnOK event then the string variable is blank. Swapping in a regular wxComboBox will say "Danish" when it appears and will set the string variable to whatever was selected when you call TransferDataFromWindow().

wxArrayString choiceStrings;
choiceStrings.Add(_("None"));
choiceStrings.Add(_("Danish"));

wxString m_langName = _("Danish");

wxBitmapComboBox* languageCombo = new wxBitmapComboBox(this, wxID_ANY,
_T(""), wxDefaultPosition, wxSize(100,
-1), choiceStrings,
wxCB_DROPDOWN|wxCB_READONLY,
wxGenericValidator(&m_langName));

Add languageCombo to a sizer or the dialog

TransferDataToWindow();

comment:3 Changed 7 years ago by p_michalczyk

I'm trying to get wxBitmapComboBox to work with validators, but there are some difficulties. This difficulties complicate solution in such a way, that this solution cannot be thought of as simple/clean. And I don't want to post dirty hacks just to make things work for a while. So please be patient. I won't forget about it.

comment:4 Changed 7 years ago by p_michalczyk

As a workaround you use BitmapComboBox without CB_READONLY style.

comment:5 Changed 6 years ago by wojdyr

  • Component set to GUI-all
  • Keywords wxBitmapComboBox wxValidator added
Note: See TracTickets for help on using tickets.