Add workaround for tabbing out of SubsTextEditCtrl

wxStyledTextCtrl eats the tabs, so handle them in
SubsTextEditCtrl::OnKeyDown()

Originally committed to SVN as r6881.
This commit is contained in:
cantabile 2012-05-28 14:18:07 +00:00 committed by Thomas Goyne
parent 571752a955
commit 3a81e80aa5
2 changed files with 11 additions and 1 deletions

View file

@ -166,6 +166,8 @@ SubsTextEditCtrl::SubsTextEditCtrl(wxWindow* parent, wxSize wsize, long style, a
using namespace std::tr1; 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::Cut, this), EDIT_MENU_CUT);
Bind(wxEVT_COMMAND_MENU_SELECTED, bind(&SubsTextEditCtrl::Copy, this), EDIT_MENU_COPY); Bind(wxEVT_COMMAND_MENU_SELECTED, bind(&SubsTextEditCtrl::Copy, this), EDIT_MENU_COPY);
Bind(wxEVT_COMMAND_MENU_SELECTED, bind(&SubsTextEditCtrl::Paste, this), EDIT_MENU_PASTE); 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)); OPT_SUB("App/Call Tips", &SubsTextEditCtrl::UpdateCallTip, this, ref(evt));
} }
SubsTextEditCtrl::~SubsTextEditCtrl() { SubsTextEditCtrl::~SubsTextEditCtrl() {
} }
@ -224,6 +225,14 @@ void SubsTextEditCtrl::OnLoseFocus(wxFocusEvent &event) {
event.Skip(); 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 { enum {
STYLE_NORMAL = 0, STYLE_NORMAL = 0,
STYLE_COMMENT, STYLE_COMMENT,

View file

@ -84,6 +84,7 @@ class SubsTextEditCtrl : public ScintillaTextCtrl {
void OnSetDicLanguage(wxCommandEvent &event); void OnSetDicLanguage(wxCommandEvent &event);
void OnSetThesLanguage(wxCommandEvent &event); void OnSetThesLanguage(wxCommandEvent &event);
void OnLoseFocus(wxFocusEvent &event); void OnLoseFocus(wxFocusEvent &event);
void OnKeyDown(wxKeyEvent &event);
void SetSyntaxStyle(int id, wxFont &font, std::string const& name); void SetSyntaxStyle(int id, wxFont &font, std::string const& name);
void Subscribe(std::string const& name); void Subscribe(std::string const& name);