From 3a81e80aa5bc73b23fcb2354e04b87b64a1a4241 Mon Sep 17 00:00:00 2001 From: cantabile Date: Mon, 28 May 2012 14:18:07 +0000 Subject: [PATCH] Add workaround for tabbing out of SubsTextEditCtrl wxStyledTextCtrl eats the tabs, so handle them in SubsTextEditCtrl::OnKeyDown() Originally committed to SVN as r6881. --- aegisub/src/subs_edit_ctrl.cpp | 11 ++++++++++- aegisub/src/subs_edit_ctrl.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/aegisub/src/subs_edit_ctrl.cpp b/aegisub/src/subs_edit_ctrl.cpp index d8e5a0d04..05cc194d8 100644 --- a/aegisub/src/subs_edit_ctrl.cpp +++ b/aegisub/src/subs_edit_ctrl.cpp @@ -166,6 +166,8 @@ SubsTextEditCtrl::SubsTextEditCtrl(wxWindow* parent, wxSize wsize, long style, a using namespace std::tr1; + Bind(wxEVT_CHAR_HOOK, &SubsTextEditCtrl::OnKeyDown, this); + Bind(wxEVT_COMMAND_MENU_SELECTED, bind(&SubsTextEditCtrl::Cut, this), EDIT_MENU_CUT); Bind(wxEVT_COMMAND_MENU_SELECTED, bind(&SubsTextEditCtrl::Copy, this), EDIT_MENU_COPY); Bind(wxEVT_COMMAND_MENU_SELECTED, bind(&SubsTextEditCtrl::Paste, this), EDIT_MENU_PASTE); @@ -199,7 +201,6 @@ SubsTextEditCtrl::SubsTextEditCtrl(wxWindow* parent, wxSize wsize, long style, a OPT_SUB("App/Call Tips", &SubsTextEditCtrl::UpdateCallTip, this, ref(evt)); } - SubsTextEditCtrl::~SubsTextEditCtrl() { } @@ -224,6 +225,14 @@ void SubsTextEditCtrl::OnLoseFocus(wxFocusEvent &event) { event.Skip(); } +void SubsTextEditCtrl::OnKeyDown(wxKeyEvent &event) { + // Workaround for wxSTC eating tabs. + if (event.GetKeyCode() == WXK_TAB) { + Navigate(event.ShiftDown() ? wxNavigationKeyEvent::IsBackward : wxNavigationKeyEvent::IsForward); + } + event.Skip(); +} + enum { STYLE_NORMAL = 0, STYLE_COMMENT, diff --git a/aegisub/src/subs_edit_ctrl.h b/aegisub/src/subs_edit_ctrl.h index db3b97ae6..68287ca2e 100644 --- a/aegisub/src/subs_edit_ctrl.h +++ b/aegisub/src/subs_edit_ctrl.h @@ -84,6 +84,7 @@ class SubsTextEditCtrl : public ScintillaTextCtrl { void OnSetDicLanguage(wxCommandEvent &event); void OnSetThesLanguage(wxCommandEvent &event); void OnLoseFocus(wxFocusEvent &event); + void OnKeyDown(wxKeyEvent &event); void SetSyntaxStyle(int id, wxFont &font, std::string const& name); void Subscribe(std::string const& name);