Update all controls using in-place editors to handle Escape/Return correctly.

Define EVT_CHAR_HOOK handlers to ensure that pressing Escape/Return while an
in-place edit control is active affects only it and is not used for the
keyboard navigation.

Closes #9102.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69897 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-12-02 00:50:41 +00:00
parent 4d7bc8e761
commit 64ac3db840
7 changed files with 143 additions and 9 deletions

View File

@@ -1461,6 +1461,12 @@ bool wxListTextCtrlWrapper::AcceptChanges()
}
void wxListTextCtrlWrapper::OnChar( wxKeyEvent &event )
{
if ( !CheckForEndEditKey(event) )
event.Skip();
}
bool wxListTextCtrlWrapper::CheckForEndEditKey(const wxKeyEvent& event)
{
switch ( event.m_keyCode )
{
@@ -1473,8 +1479,10 @@ void wxListTextCtrlWrapper::OnChar( wxKeyEvent &event )
break;
default:
event.Skip();
return false;
}
return true;
}
void wxListTextCtrlWrapper::OnKeyUp( wxKeyEvent &event )
@@ -1518,6 +1526,7 @@ void wxListTextCtrlWrapper::OnKillFocus( wxFocusEvent &event )
BEGIN_EVENT_TABLE(wxListMainWindow, wxWindow)
EVT_PAINT (wxListMainWindow::OnPaint)
EVT_MOUSE_EVENTS (wxListMainWindow::OnMouse)
EVT_CHAR_HOOK (wxListMainWindow::OnCharHook)
EVT_CHAR (wxListMainWindow::OnChar)
EVT_KEY_DOWN (wxListMainWindow::OnKeyDown)
EVT_KEY_UP (wxListMainWindow::OnKeyUp)
@@ -2713,6 +2722,22 @@ void wxListMainWindow::OnKeyUp( wxKeyEvent &event )
event.Skip();
}
void wxListMainWindow::OnCharHook( wxKeyEvent &event )
{
if ( m_textctrlWrapper )
{
// When an in-place editor is active we should ensure that it always
// gets the key events that are special to it.
if ( m_textctrlWrapper->CheckForEndEditKey(event) )
{
// Skip the call to wxEvent::Skip() below.
return;
}
}
event.Skip();
}
void wxListMainWindow::OnChar( wxKeyEvent &event )
{
wxWindow *parent = GetParent();