forked from mia/Aegisub
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:
parent
9269c79763
commit
a15024e052
2 changed files with 13 additions and 2 deletions
|
@ -89,11 +89,12 @@ TimeEdit::TimeEdit(wxWindow* parent, wxWindowID id, agi::Context *c, const wxStr
|
||||||
// Other stuff
|
// Other stuff
|
||||||
if (!value) SetValue(time.GetASSFormated());
|
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_COMMAND_TEXT_UPDATED, &TimeEdit::OnModified, this);
|
||||||
Bind(wxEVT_CONTEXT_MENU, &TimeEdit::OnContextMenu, this);
|
Bind(wxEVT_CONTEXT_MENU, &TimeEdit::OnContextMenu, this);
|
||||||
Bind(wxEVT_KEY_DOWN, &TimeEdit::OnKeyDown, 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);
|
Bind(wxEVT_KILL_FOCUS, &TimeEdit::OnFocusLost, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,6 +140,15 @@ void TimeEdit::UpdateText() {
|
||||||
ChangeValue(time.GetASSFormated());
|
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) {
|
void TimeEdit::OnKeyDown(wxKeyEvent &event) {
|
||||||
int key = event.GetKeyCode();
|
int key = event.GetKeyCode();
|
||||||
if (event.CmdDown()) {
|
if (event.CmdDown()) {
|
||||||
|
|
|
@ -69,6 +69,7 @@ class TimeEdit : public wxTextCtrl {
|
||||||
void OnContextMenu(wxContextMenuEvent &event);
|
void OnContextMenu(wxContextMenuEvent &event);
|
||||||
void OnFocusLost(wxFocusEvent &evt);
|
void OnFocusLost(wxFocusEvent &evt);
|
||||||
void OnInsertChanged(agi::OptionValue const& opt);
|
void OnInsertChanged(agi::OptionValue const& opt);
|
||||||
|
void OnCharHook(wxKeyEvent &event);
|
||||||
void OnKeyDown(wxKeyEvent &event);
|
void OnKeyDown(wxKeyEvent &event);
|
||||||
void OnModified(wxCommandEvent &event);
|
void OnModified(wxCommandEvent &event);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue