Normalize the value of the time edit controls when they lose focus. Updates #512.

Originally committed to SVN as r6125.
This commit is contained in:
Thomas Goyne 2011-12-22 21:29:18 +00:00
parent 5cbd35e749
commit 3cdc27c894
2 changed files with 8 additions and 0 deletions

View File

@ -94,6 +94,7 @@ TimeEdit::TimeEdit(wxWindow* parent, wxWindowID id, agi::Context *c, const wxStr
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::CopyTime, this), Time_Edit_Copy);
Bind(wxEVT_COMMAND_MENU_SELECTED, std::tr1::bind(&TimeEdit::PasteTime, this), Time_Edit_Paste); Bind(wxEVT_COMMAND_MENU_SELECTED, std::tr1::bind(&TimeEdit::PasteTime, this), Time_Edit_Paste);
Bind(wxEVT_KILL_FOCUS, &TimeEdit::OnFocusLost, this);
} }
void TimeEdit::SetTime(AssTime new_time) { void TimeEdit::SetTime(AssTime new_time) {
@ -201,6 +202,12 @@ void TimeEdit::OnContextMenu(wxContextMenuEvent &evt) {
PopupMenu(&menu); PopupMenu(&menu);
} }
void TimeEdit::OnFocusLost(wxFocusEvent &evt) {
if (insert || byFrame)
UpdateText();
evt.Skip();
}
void TimeEdit::CopyTime() { void TimeEdit::CopyTime() {
if (wxTheClipboard->Open()) { if (wxTheClipboard->Open()) {
wxTheClipboard->SetData(new wxTextDataObject(GetValue())); wxTheClipboard->SetData(new wxTextDataObject(GetValue()));

View File

@ -67,6 +67,7 @@ class TimeEdit : public wxTextCtrl {
void UpdateText(); void UpdateText();
void OnContextMenu(wxContextMenuEvent &event); void OnContextMenu(wxContextMenuEvent &event);
void OnFocusLost(wxFocusEvent &evt);
void OnInsertChanged(agi::OptionValue const& opt); void OnInsertChanged(agi::OptionValue const& opt);
void OnKeyDown(wxKeyEvent &event); void OnKeyDown(wxKeyEvent &event);
void OnModified(wxCommandEvent &event); void OnModified(wxCommandEvent &event);