From 5ccff948738c69d7bbc75324414f00300301da7e Mon Sep 17 00:00:00 2001 From: Florian Rival Date: Sun, 5 Oct 2014 15:39:20 +0200 Subject: [PATCH] Fix keyboard shortcuts not working in events editor with wxGTK --- IDE/EventsEditor.cpp | 15 +++++++++++---- IDE/EventsEditor.h | 2 +- IDE/wxsmith/EventsEditor.wxs | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/IDE/EventsEditor.cpp b/IDE/EventsEditor.cpp index a884953a595..8a78caff4ef 100644 --- a/IDE/EventsEditor.cpp +++ b/IDE/EventsEditor.cpp @@ -155,7 +155,7 @@ void EventsEditor::Init(wxWindow* parent) FlexGridSizer1 = new wxFlexGridSizer(0, 2, 0, 0); FlexGridSizer1->AddGrowableCol(0); FlexGridSizer1->AddGrowableRow(0); - eventsPanel = new wxPanel(this, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL1")); + eventsPanel = new wxControl(this, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, wxDefaultValidator, _T("ID_PANEL1")); eventsPanel->SetBackgroundColour(wxColour(255,255,255)); liveEditingPanel = new wxPanel(eventsPanel, ID_PANEL2, wxPoint(100,100), wxDefaultSize, wxSIMPLE_BORDER, _T("ID_PANEL2")); FlexGridSizer2 = new wxFlexGridSizer(0, 3, 0, 0); @@ -298,6 +298,13 @@ void EventsEditor::Init(wxWindow* parent) addInstrBt->Connect(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(EventsEditor::OnaddInstrIconPnlMouseLeave), NULL, this); addInstrIcon->Connect(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(EventsEditor::OnaddInstrIconPnlMouseLeave), NULL, this); + //Ensure that the eventsPanel is a wxControl: if declared as a wxPanel, it + //won't be able to catch keyboard input. + if (dynamic_cast(eventsPanel)) + { + std::cout << "ERROR: eventsPanel was declared as a wxPanel instead of wxControl! Keyboards shortcut won't work with wxGTK."; + } + //Load configuration wxConfigBase * config = wxConfigBase::Get(); conditionColumnWidth = config->ReadDouble("EventsEditor/ConditionColumnWidth", 350); @@ -751,7 +758,7 @@ void EventsEditor::OneventsPanelLeftUp(wxMouseEvent& event) void EventsEditor::OneventsPanelLeftDown(wxMouseEvent& event) { - eventsPanel->SetFocusIgnoringChildren(); + eventsPanel->SetFocus(); //Want to resize conditions column ? if ( event.GetX() >= conditionColumnWidth-2 && event.GetX() <= conditionColumnWidth+2 ) @@ -945,7 +952,7 @@ void EventsEditor::OneventsPanelLeftDClick(wxMouseEvent& event) void EventsEditor::OneventsPanelMouseMove(wxMouseEvent& event) { if (!liveEditingPanel->IsShown()) - eventsPanel->SetFocusIgnoringChildren(); + eventsPanel->SetFocus(); //Column resizing if ( (event.GetX() >= conditionColumnWidth-2 && event.GetX() <= conditionColumnWidth+2) || isResizingColumns) @@ -1180,7 +1187,7 @@ void EventsEditor::EndLiveEditing() return; } - eventsPanel->SetFocusIgnoringChildren(); + eventsPanel->SetFocus(); *liveEditedParameter.parameter = gd::Expression(ToString(liveEdit->GetValue())); liveEditedParameter.event->eventHeightNeedUpdate = true; liveEditingPanel->Show(false); diff --git a/IDE/EventsEditor.h b/IDE/EventsEditor.h index 503b07af4d3..9536a6f3659 100644 --- a/IDE/EventsEditor.h +++ b/IDE/EventsEditor.h @@ -144,7 +144,7 @@ class EventsEditor: public wxPanel wxPanel* listContextPanel; wxMenuItem* MenuItem6; wxMenu eventTypesMenu; - wxPanel* eventsPanel; + wxControl* eventsPanel; wxStaticText* addInstrBt; wxMenuItem* eventCopyMenu; wxMenu multipleContextMenu; diff --git a/IDE/wxsmith/EventsEditor.wxs b/IDE/wxsmith/EventsEditor.wxs index df386b90367..eb1a7ee1e5c 100644 --- a/IDE/wxsmith/EventsEditor.wxs +++ b/IDE/wxsmith/EventsEditor.wxs @@ -9,7 +9,7 @@ 0 0 - + #FFFFFF