diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-05-23 23:51:09 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-05-24 23:33:08 +0100 |
| commit | 67e67ea42fcfd2a0805fd96f44a2435992a3320e (patch) | |
| tree | a477a6b7a9c18cd0e6e6821bbebaece9514259d4 /src/wx/focus_manager.cc | |
| parent | 28c3c789cc903c5737902f4403b63765c9115089 (diff) | |
Try another way of fixing accelerators stealing text control arrow keys (#1263).
Diffstat (limited to 'src/wx/focus_manager.cc')
| -rw-r--r-- | src/wx/focus_manager.cc | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/wx/focus_manager.cc b/src/wx/focus_manager.cc new file mode 100644 index 000000000..f4f23cb28 --- /dev/null +++ b/src/wx/focus_manager.cc @@ -0,0 +1,55 @@ +/* + Copyright (C) 2018 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 "focus_manager.h" +#include <wx/textctrl.h> + +FocusManager* FocusManager::_instance; + +FocusManager * +FocusManager::instance() +{ + if (!_instance) { + _instance = new FocusManager(); + } + + return _instance; +} + +void +FocusManager::set_focus (wxFocusEvent& ev) +{ + SetFocus(); + ev.Skip(); +} + +void +FocusManager::kill_focus (wxFocusEvent& ev) +{ + KillFocus(); + ev.Skip(); +} + +void +FocusManager::add(wxTextCtrl* c) +{ + c->Bind(wxEVT_SET_FOCUS, boost::bind(&FocusManager::set_focus, this, _1)); + c->Bind(wxEVT_KILL_FOCUS, boost::bind(&FocusManager::kill_focus, this, _1)); +} |
