From 86f14a033cf23870de4ab8d0930e741a02addef7 Mon Sep 17 00:00:00 2001 From: Ilya Sinitsyn Date: Wed, 9 Oct 2019 21:14:43 +0700 Subject: [PATCH] Fix the issue with the grid cell editor special chars handling Some of the grid cell editors (all of them not based on wxTextCtrl basically, i.e. wxGridCellBoolEditor, wxGridCellChoiceEditor, wxGridCellEnumEditor) didn't process Esc, Enter and Tab under MSW, making them inconvenient to use. Fix this by adding wxWANTS_CHARS style flag to ensure the editors do get these keys. Closes https://github.com/wxWidgets/wxWidgets/pull/1598 --- src/generic/grid.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 852eabf884..447efc3d9e 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -6996,12 +6996,22 @@ void wxGrid::ShowCellEditControl() editor->Create(gridWindow, wxID_ANY, new wxGridCellEditorEvtHandler(this, editor)); + // Ensure the editor window has wxWANTS_CHARS flag, so that it + // gets Tab, Enter and Esc keys, which need to be processed + // specially by wxGridCellEditorEvtHandler. + wxWindow* const editorWindow = editor->GetWindow(); + if ( editorWindow ) + { + editorWindow->SetWindowStyle(editorWindow->GetWindowStyle() + | wxWANTS_CHARS); + } + wxGridEditorCreatedEvent evt(GetId(), wxEVT_GRID_EDITOR_CREATED, this, row, col, - editor->GetWindow()); + editorWindow); GetEventHandler()->ProcessEvent(evt); } else if ( editor->GetWindow() &&