diff --git a/aegisub/src/timeedit_ctrl.cpp b/aegisub/src/timeedit_ctrl.cpp index 47c38b988..23abf5d34 100644 --- a/aegisub/src/timeedit_ctrl.cpp +++ b/aegisub/src/timeedit_ctrl.cpp @@ -89,11 +89,12 @@ 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); Bind(wxEVT_CONTEXT_MENU, &TimeEdit::OnContextMenu, this); Bind(wxEVT_KEY_DOWN, &TimeEdit::OnKeyDown, 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_KILL_FOCUS, &TimeEdit::OnFocusLost, this); } @@ -139,6 +140,15 @@ 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 30aa68063..a9b3c99ba 100644 --- a/aegisub/src/timeedit_ctrl.h +++ b/aegisub/src/timeedit_ctrl.h @@ -69,6 +69,7 @@ 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);