From d31b795e60570077156de515d6acc1136a9f02aa Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Tue, 15 May 2012 13:40:00 +0000 Subject: [PATCH] Move the logic for Enter in a time edit to SubsEditBox It doesn't make any sense for the time edits used elsewhere, and it made Enter in a time edit not close dialogs. Originally committed to SVN as r6790. --- aegisub/src/subs_edit_box.cpp | 11 +++++++++++ aegisub/src/timeedit_ctrl.cpp | 10 ---------- aegisub/src/timeedit_ctrl.h | 1 - 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/aegisub/src/subs_edit_box.cpp b/aegisub/src/subs_edit_box.cpp index ebe00f07c..31e885592 100644 --- a/aegisub/src/subs_edit_box.cpp +++ b/aegisub/src/subs_edit_box.cpp @@ -134,6 +134,16 @@ void change_value(wxTextCtrl *ctrl, wxString const& value) { ctrl->ChangeValue(value); } +void time_edit_char_hook(wxKeyEvent &event) { + // Force a modified event on Enter + if (event.GetKeyCode() == WXK_RETURN) { + TimeEdit *edit = static_cast(event.GetEventObject()); + edit->SetValue(edit->GetValue()); + } + else + event.Skip(); +} + } SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context) @@ -255,6 +265,7 @@ TimeEdit *SubsEditBox::MakeTimeCtrl(bool end, wxString const& tooltip, void (Sub TimeEdit *ctrl = new TimeEdit(this, -1, c, "", wxSize(75,-1), end); ctrl->SetToolTip(tooltip); Bind(wxEVT_COMMAND_TEXT_UPDATED, handler, this, ctrl->GetId()); + ctrl->Bind(wxEVT_CHAR_HOOK, time_edit_char_hook); MiddleSizer->Add(ctrl, wxSizerFlags().Center()); return ctrl; } diff --git a/aegisub/src/timeedit_ctrl.cpp b/aegisub/src/timeedit_ctrl.cpp index 23abf5d34..11a621f85 100644 --- a/aegisub/src/timeedit_ctrl.cpp +++ b/aegisub/src/timeedit_ctrl.cpp @@ -89,7 +89,6 @@ TimeEdit::TimeEdit(wxWindow* parent, wxWindowID id, agi::Context *c, const wxStr // Other stuff if (!value) SetValue(time.GetASSFormated()); - Bind(wxEVT_CHAR_HOOK, &TimeEdit::OnCharHook, this); Bind(wxEVT_COMMAND_MENU_SELECTED, std::tr1::bind(&TimeEdit::CopyTime, this), Time_Edit_Copy); Bind(wxEVT_COMMAND_MENU_SELECTED, std::tr1::bind(&TimeEdit::PasteTime, this), Time_Edit_Paste); Bind(wxEVT_COMMAND_TEXT_UPDATED, &TimeEdit::OnModified, this); @@ -140,15 +139,6 @@ void TimeEdit::UpdateText() { ChangeValue(time.GetASSFormated()); } -void TimeEdit::OnCharHook(wxKeyEvent &event) { - // Force a modified event on Enter - // Can't be done in OnKeyDown as the SubsEditBox hotkey would grab it first - if (event.GetKeyCode() == WXK_RETURN) - SetValue(GetValue()); - else - event.Skip(); -} - void TimeEdit::OnKeyDown(wxKeyEvent &event) { int key = event.GetKeyCode(); if (event.CmdDown()) { diff --git a/aegisub/src/timeedit_ctrl.h b/aegisub/src/timeedit_ctrl.h index a9b3c99ba..30aa68063 100644 --- a/aegisub/src/timeedit_ctrl.h +++ b/aegisub/src/timeedit_ctrl.h @@ -69,7 +69,6 @@ class TimeEdit : public wxTextCtrl { void OnContextMenu(wxContextMenuEvent &event); void OnFocusLost(wxFocusEvent &evt); void OnInsertChanged(agi::OptionValue const& opt); - void OnCharHook(wxKeyEvent &event); void OnKeyDown(wxKeyEvent &event); void OnModified(wxCommandEvent &event);