mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 15:25:01 +01:00
change API for CairoWidget::focus_handler
This functor/closure is responsible for stealing focus from any existing text entry (or whatever else may have focus) when clicking on a CairoWidget or derived class. The old implementation just gave focus back to the editor canvas. The new version walks up the widget packing heirarchy to find a focusable parent (from the CairoWidget for which it is invoked). If no focusable parent is found, it cancels keyboard focus in the toplevel window containing the CairoWidget
This commit is contained in:
parent
a8f242f80a
commit
9a11e3a64d
9 changed files with 44 additions and 14 deletions
|
|
@ -1739,9 +1739,40 @@ Editor::parameter_changed (std::string p)
|
|||
}
|
||||
|
||||
void
|
||||
Editor::reset_focus ()
|
||||
Editor::reset_focus (Gtk::Widget* w)
|
||||
{
|
||||
_track_canvas->grab_focus();
|
||||
/* this resets focus to the first focusable parent of the given widget,
|
||||
* or, if there is no focusable parent, cancels focus in the toplevel
|
||||
* window that the given widget is packed into (if there is one).
|
||||
*/
|
||||
|
||||
if (!w) {
|
||||
return;
|
||||
}
|
||||
|
||||
Gtk::Widget* top = w->get_toplevel();
|
||||
|
||||
if (!top || !top->is_toplevel()) {
|
||||
return;
|
||||
}
|
||||
|
||||
w = w->get_parent ();
|
||||
|
||||
while (w) {
|
||||
if (w->get_can_focus ()) {
|
||||
Window* win = dynamic_cast<Window*> (top);
|
||||
win->set_focus (*w);
|
||||
return;
|
||||
}
|
||||
w = w->get_parent ();
|
||||
}
|
||||
|
||||
/* no focusable parent found, cancel focus in top level window.
|
||||
C++ API cannot be used for this. Thanks, references.
|
||||
*/
|
||||
|
||||
gtk_window_set_focus (GTK_WINDOW(top->gobj()), 0);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue