From 023e5ad3d9e704fb63e43bb45a0f279c1fdc3a0f Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 15 Jan 2025 21:58:07 +0100 Subject: Move onto next timecode control after typing two characters. --- src/wx/timecode.cc | 23 ++++++++++++++++++++--- 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; -- cgit v1.2.3