Allow custom handling of Enter/Tab with modifiers in wxDataViewCtrl

While Enter and Tab on their own should be used to finish cell editing, the
cell editor itself may want to process key combinations involving these keys
with modifiers, e.g. Shift-Enter, so don't intercept those in at least the
generic version of wxDataViewCtrl to allow catching them in the editor.
This commit is contained in:
Vadim Zeitlin
2015-11-18 22:56:09 +01:00
parent 5591a20093
commit 6b2a6baf2e
2 changed files with 20 additions and 7 deletions

View File

@@ -1044,17 +1044,20 @@ void wxDataViewEditorCtrlEvtHandler::OnChar( wxKeyEvent &event )
{ {
switch ( event.m_keyCode ) switch ( event.m_keyCode )
{ {
case WXK_RETURN:
m_finished = true;
m_owner->FinishEditing();
break;
case WXK_ESCAPE: case WXK_ESCAPE:
{
m_finished = true; m_finished = true;
m_owner->CancelEditing(); m_owner->CancelEditing();
break; break;
}
case WXK_RETURN:
if ( !event.HasAnyModifiers() )
{
m_finished = true;
m_owner->FinishEditing();
break;
}
wxFALLTHROUGH; // Ctrl/Alt/Shift-Enter is not handled specially
default: default:
event.Skip(); event.Skip();
} }

View File

@@ -3632,7 +3632,17 @@ void wxDataViewMainWindow::OnCharHook(wxKeyEvent& event)
return; return;
case WXK_RETURN: case WXK_RETURN:
// Shift-Enter is not special neither.
if ( event.ShiftDown() )
break;
wxFALLTHROUGH;
case WXK_TAB: case WXK_TAB:
// Ctrl/Alt-Tab or Enter could be used for something else, so
// don't handle them here.
if ( event.HasModifiers() )
break;
m_editorRenderer->FinishEditing(); m_editorRenderer->FinishEditing();
return; return;
} }