added code showing that at least under Windows wxCombobox::GetSelection() return value changes even before EVT_COMBOBOX is sent

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35196 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2005-08-16 12:13:56 +00:00
parent a2ec9439a3
commit f226be17ad

View File

@@ -77,6 +77,7 @@ public:
virtual ~MyPanel(); virtual ~MyPanel();
void OnSize( wxSizeEvent& event ); void OnSize( wxSizeEvent& event );
void OnIdle( wxIdleEvent &event );
void OnListBox( wxCommandEvent &event ); void OnListBox( wxCommandEvent &event );
void OnListBoxDoubleClick( wxCommandEvent &event ); void OnListBoxDoubleClick( wxCommandEvent &event );
void OnListBoxButtons( wxCommandEvent &event ); void OnListBoxButtons( wxCommandEvent &event );
@@ -481,6 +482,7 @@ const int ID_SIZER_CHECKBIG = 206;
BEGIN_EVENT_TABLE(MyPanel, wxPanel) BEGIN_EVENT_TABLE(MyPanel, wxPanel)
EVT_SIZE ( MyPanel::OnSize) EVT_SIZE ( MyPanel::OnSize)
EVT_IDLE ( MyPanel::OnIdle)
EVT_BOOKCTRL_PAGE_CHANGING(ID_BOOK, MyPanel::OnPageChanging) EVT_BOOKCTRL_PAGE_CHANGING(ID_BOOK, MyPanel::OnPageChanging)
EVT_BOOKCTRL_PAGE_CHANGED(ID_BOOK, MyPanel::OnPageChanged) EVT_BOOKCTRL_PAGE_CHANGED(ID_BOOK, MyPanel::OnPageChanged)
EVT_LISTBOX (ID_LISTBOX, MyPanel::OnListBox) EVT_LISTBOX (ID_LISTBOX, MyPanel::OnListBox)
@@ -1049,6 +1051,26 @@ void MyPanel::OnSize( wxSizeEvent& WXUNUSED(event) )
if (m_text) m_text->SetSize( 2, y*2/3+2, x-4, y/3-4 ); if (m_text) m_text->SetSize( 2, y*2/3+2, x-4, y/3-4 );
} }
void MyPanel::OnIdle(wxIdleEvent& event)
{
static const int INVALID_SELECTION = -2;
static int s_selCombo = INVALID_SELECTION;
int sel = m_combo->GetSelection();
if ( sel != s_selCombo )
{
if ( s_selCombo != INVALID_SELECTION )
{
wxLogMessage(_T("EVT_IDLE: combobox selection changed from %d to %d"),
s_selCombo, sel);
}
s_selCombo = sel;
}
event.Skip();
}
void MyPanel::OnPageChanging( wxBookCtrlEvent &event ) void MyPanel::OnPageChanging( wxBookCtrlEvent &event )
{ {
int selOld = event.GetOldSelection(); int selOld = event.GetOldSelection();
@@ -1326,20 +1348,18 @@ void MyPanel::OnChoiceButtons( wxCommandEvent &event )
void MyPanel::OnCombo( wxCommandEvent &event ) void MyPanel::OnCombo( wxCommandEvent &event )
{ {
m_text->AppendText( _T("ComboBox event selection string is: ") ); wxLogMessage(_T("EVT_COMBOBOX: item %d/%d (event/control), string \"%s\"/\"%s\""),
m_text->AppendText( event.GetString() ); event.GetInt(),
m_text->AppendText( _T("\n") ); m_combo->GetSelection(),
m_text->AppendText( _T("ComboBox control selection string is: ") ); event.GetString().c_str(),
m_text->AppendText( m_combo->GetStringSelection() ); m_combo->GetStringSelection().c_str());
m_text->AppendText( _T("\n") );
} }
void MyPanel::OnComboTextChanged(wxCommandEvent& event) void MyPanel::OnComboTextChanged(wxCommandEvent& event)
{ {
wxString str; wxLogMessage(wxT("EVT_TEXT for the combobox: \"%s\" (event) or \"%s\" (control)."),
str.Printf( wxT("Text in the combobox changed: now is '%s'."), event.GetString().c_str(),
event.GetString().c_str() ); m_combo->GetValue().c_str());
wxLogMessage( str.c_str() );
} }
void MyPanel::OnComboTextEnter(wxCommandEvent& WXUNUSED(event)) void MyPanel::OnComboTextEnter(wxCommandEvent& WXUNUSED(event))
@@ -1737,10 +1757,13 @@ void MyFrame::OnQuit (wxCommandEvent& WXUNUSED(event) )
void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) ) void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
{ {
SetSize(800, 600);
#if 0
wxBusyCursor bc; wxBusyCursor bc;
wxMessageDialog dialog(this, _T("This is a control sample"), _T("About Controls"), wxOK ); wxMessageDialog dialog(this, _T("This is a control sample"), _T("About Controls"), wxOK );
dialog.ShowModal(); dialog.ShowModal();
#endif
} }
void MyFrame::OnClearLog(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnClearLog(wxCommandEvent& WXUNUSED(event))