diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-03-29 22:27:35 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-03-29 22:38:28 +0200 |
| commit | 5baecb091f5f3f956be002668ce74291c7826b95 (patch) | |
| tree | b9583297ce05ddf133ed441dac946b439b8d0fb2 /src/wx/dcpomatic_spin_ctrl.cc | |
| parent | 25142b529304096d22baf885c45ba41bce480b72 (diff) | |
Fix strange problems with spin entries on macOS (#1944).
SetRange() with minimum > 0 seems to stop entry of numbers by selecting
the existing one and typing new. Also we can make Enter work properly
by adding a handler.
Diffstat (limited to 'src/wx/dcpomatic_spin_ctrl.cc')
| -rw-r--r-- | src/wx/dcpomatic_spin_ctrl.cc | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/wx/dcpomatic_spin_ctrl.cc b/src/wx/dcpomatic_spin_ctrl.cc new file mode 100644 index 000000000..e8f2fdbc7 --- /dev/null +++ b/src/wx/dcpomatic_spin_ctrl.cc @@ -0,0 +1,38 @@ +/* + Copyright (C) 2021 Carl Hetherington <cth@carlh.net> + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. + +*/ + + +#include "dcpomatic_spin_ctrl.h" +#include <boost/bind.hpp> +#include <wx/wx.h> +#if BOOST_VERSION >= 106100 +using namespace boost::placeholders; +#endif + + +SpinCtrl::SpinCtrl (wxWindow* parent, int width) + : wxSpinCtrl (parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(width, -1), wxSP_ARROW_KEYS | wxTE_PROCESS_ENTER) +{ + auto enter = [](wxCommandEvent& ev) { + dynamic_cast<wxWindow*>(ev.GetEventObject())->Navigate(); + }; + Bind (wxEVT_TEXT_ENTER, boost::bind<void>(enter, _1)); +} + |
