git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36890
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
{
// when the popup is hidden, throw a SELECTED event only if the combobox
// selection changed.
{
// when the popup is hidden, throw a SELECTED event only if the combobox
// selection changed.
- int curSelection = combo->GetCurrentSelection();
- if (g_SelectionBeforePopup != curSelection)
+ const int curSelection = combo->GetCurrentSelection();
+
+ const bool hasChanged = curSelection != g_SelectionBeforePopup;
+
+ // reset the selection flag to value meaning that it is hidden and do it
+ // now, before generating the events, so that GetSelection() returns the
+ // new value from the event handler
+ g_SelectionBeforePopup = wxID_NONE;
+
+ if ( hasChanged )
{
wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() );
event.SetInt( curSelection );
{
wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() );
event.SetInt( curSelection );
event2.SetEventObject( combo );
combo->GetEventHandler()->ProcessEvent( event2 );
}
event2.SetEventObject( combo );
combo->GetEventHandler()->ProcessEvent( event2 );
}
-
- // reset the selection flag to value meaning that it is hidden
- g_SelectionBeforePopup = wxID_NONE;
{
// when the popup is hidden, throw a SELECTED event only if the combobox
// selection changed.
{
// when the popup is hidden, throw a SELECTED event only if the combobox
// selection changed.
- int curSelection = combo->GetCurrentSelection();
- if (g_SelectionBeforePopup != curSelection)
+ const int curSelection = combo->GetCurrentSelection();
+
+ const bool hasChanged = curSelection != g_SelectionBeforePopup;
+
+ // reset the selection flag to value meaning that it is hidden and do it
+ // now, before generating the events, so that GetSelection() returns the
+ // new value from the event handler
+ g_SelectionBeforePopup = wxID_NONE;
+
+ if ( hasChanged )
{
wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() );
event.SetInt( curSelection );
{
wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() );
event.SetInt( curSelection );
event2.SetEventObject( combo );
combo->GetEventHandler()->ProcessEvent( event2 );
}
event2.SetEventObject( combo );
combo->GetEventHandler()->ProcessEvent( event2 );
}
-
- // reset the selection flag to value meaning that it is hidden
- g_SelectionBeforePopup = wxID_NONE;