Trigger a modified event on Enter in a time edit so that selecting several lines and hitting Enter to set them all to the active line's time works

Originally committed to SVN as r6750.
This commit is contained in:
Thomas Goyne 2012-05-04 02:53:14 +00:00
parent 9269c79763
commit a15024e052
2 changed files with 13 additions and 2 deletions

View File

@ -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()) {

View File

@ -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);