Make wxChoice and wxComboBox behaviour same as in native controls in wxMSW.

Keep the item selected from the drop down using keyboard when switching away
from the control by pressing TAB: although this generates CBN_SELENDCANCEL
notification, the selection is actually kept by the native controls in this
case, so don't reset it ourselves -- even though it makes sense, it makes wx
applications behave differently from the native ones.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73103 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-12-02 23:49:25 +00:00
parent 7bc740719c
commit 65676a2882
3 changed files with 48 additions and 30 deletions

View File

@@ -274,26 +274,27 @@ bool wxComboBox::MSWCommand(WXUINT param, WXWORD id)
case CBN_DROPDOWN:
// remember the last selection, just as wxChoice does
m_lastAcceptedSelection = GetCurrentSelection();
if ( m_lastAcceptedSelection == -1 )
{
// but unlike with wxChoice we may have no selection but still
// have some text and we should avoid erasing it if the drop
// down is cancelled (see #8474)
m_lastAcceptedSelection = wxID_NONE;
}
{
wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_DROPDOWN, GetId());
event.SetEventObject(this);
ProcessCommand(event);
}
break;
case CBN_CLOSEUP:
// Do the same thing as in wxChoice but using different event type.
if ( m_pendingSelection != wxID_NONE )
{
SendSelectionChangedEvent(wxEVT_COMMAND_COMBOBOX_SELECTED);
m_pendingSelection = wxID_NONE;
}
{
wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_CLOSEUP, GetId());
event.SetEventObject(this);
ProcessCommand(event);
}
break;
case CBN_SELENDOK:
#ifndef __SMARTPHONE__
// we need to reset this to prevent the selection from being undone