diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-01-15 21:58:07 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-01-15 21:58:07 +0100 |
| commit | 023e5ad3d9e704fb63e43bb45a0f279c1fdc3a0f (patch) | |
| tree | 1b4c680dab33736d06e25bf72f4bad379f1a2815 | |
| parent | b23517142c52c52a72a3c8a685ee0e8d2b256372 (diff) | |
Move onto next timecode control after typing two characters.
| -rw-r--r-- | src/wx/timecode.cc | 23 | ||||
| -rw-r--r-- | src/wx/timecode.h | 2 |
2 files changed, 21 insertions, 4 deletions
diff --git a/src/wx/timecode.cc b/src/wx/timecode.cc index 856093919..63c119a18 100644 --- a/src/wx/timecode.cc +++ b/src/wx/timecode.cc @@ -26,6 +26,9 @@ using std::string; +#if BOOST_VERSION >= 106100 +using namespace boost::placeholders; +#endif TimecodeBase::TimecodeBase (wxWindow* parent, bool set_button) @@ -75,7 +78,7 @@ TimecodeBase::TimecodeBase (wxWindow* parent, bool set_button) _fixed = add_label_to_sizer(_sizer, this, char_to_wx("42"), false, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL); for (auto control: _controls) { - control->Bind(wxEVT_TEXT, boost::bind(&TimecodeBase::changed, this)); + control->Bind(wxEVT_TEXT, boost::bind(&TimecodeBase::changed, this, _1)); } if (_set_button) { _set_button->Bind (wxEVT_BUTTON, boost::bind (&TimecodeBase::set_clicked, this)); @@ -103,11 +106,25 @@ TimecodeBase::clear () } void -TimecodeBase::changed () +TimecodeBase::changed(wxCommandEvent& ev) { - if (_set_button && !_ignore_changed) { + if (_ignore_changed) { + return; + } + + if (_set_button) { _set_button->Enable(valid()); } + + auto iter = std::find(_controls.begin(), _controls.end(), ev.GetEventObject()); + DCPOMATIC_ASSERT(iter != _controls.end()); + + if ((*iter)->GetValue().Length() == 2) { + auto next = std::next(iter); + if (next != _controls.end()) { + (*next)->SetFocus(); + } + } } void diff --git a/src/wx/timecode.h b/src/wx/timecode.h index 64d2e311b..ed78f9428 100644 --- a/src/wx/timecode.h +++ b/src/wx/timecode.h @@ -49,7 +49,7 @@ public: static wxSize size (wxWindow* parent); protected: - void changed (); + void changed(wxCommandEvent& ev); void set_clicked (); virtual bool valid() const = 0; |
