diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index 7255bc38bc..c574ff7ee9 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -183,6 +183,28 @@ private: DECLARE_EVENT_TABLE() }; +// a combo which intercepts chars (to test Windows behaviour) +class MyComboBox : public wxComboBox +{ +public: + MyComboBox(wxWindow *parent, wxWindowID id, + const wxString& value = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + int n = 0, const wxString choices[] = NULL, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxComboBoxNameStr) + : wxComboBox(parent, id, value, pos, size, n, choices, style, + validator, name) { } + +protected: + void OnChar(wxKeyEvent& event); + +private: + DECLARE_EVENT_TABLE() +}; + //---------------------------------------------------------------------- // other //---------------------------------------------------------------------- @@ -387,6 +409,14 @@ EVT_BUTTON (ID_BUTTON_TEST2, MyPanel::OnTestButton) EVT_BUTTON (ID_BITMAP_BTN, MyPanel::OnBmpButton) END_EVENT_TABLE() +BEGIN_EVENT_TABLE(MyComboBox, wxComboBox) + EVT_CHAR(MyComboBox::OnChar) +END_EVENT_TABLE() + +// ============================================================================ +// implementation +// ============================================================================ + MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : wxPanel( frame, -1, wxPoint(x, y), wxSize(w, h) ), m_text(NULL), m_notebook(NULL) @@ -532,7 +562,8 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) panel = new wxPanel(m_notebook); (void)new wxStaticBox( panel, -1, "&Box around combobox", wxPoint(5, 5), wxSize(150, 100)); - m_combo = new wxComboBox( panel, ID_COMBO, "This", wxPoint(20,25), wxSize(120,-1), 5, choices, wxCB_READONLY ); + m_combo = new MyComboBox( panel, ID_COMBO, "This", wxPoint(20,25), + wxSize(120,-1), 5, choices); //, wxCB_READONLY ); (void)new wxButton( panel, ID_COMBO_SEL_NUM, "Select #&2", wxPoint(180,30), wxSize(140,30) ); (void)new wxButton( panel, ID_COMBO_SEL_STR, "&Select 'This'", wxPoint(340,30), wxSize(140,30) ); (void)new wxButton( panel, ID_COMBO_CLEAR, "&Clear", wxPoint(180,80), wxSize(140,30) ); @@ -1323,6 +1354,11 @@ void MyFrame::OnIdle( wxIdleEvent& WXUNUSED(event) ) } } +void MyComboBox::OnChar(wxKeyEvent& WXUNUSED(event)) +{ + wxLogMessage(_T("MyComboBox::OnChar")); +} + static void SetControlClientData(const char *name, wxControlWithItems *control) {