diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-07-16 15:49:33 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-07-18 16:47:50 +0200 |
commit | f497a4e9da5d2375e428b03c423cc2d2e9995c4a (patch) | |
tree | f3aa3a6f60ac14f47599e0f1ad2a5f9f0c20b68d /vcl | |
parent | c85557c924ee83f9a29c07520c83d308ff5a4c79 (diff) |
Related: tdf#143357 restore focus to MenuButton when popover pops down
which already happens for ComboBoxes but not always for MenuButtons with
popovers with widgets in them
Change-Id: If2ab1934f582b01327f910a578b80e9462d3daa0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119078
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/unx/gtk3/gtkinst.cxx | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index f82ab5d105cc..f79e3c35fbf0 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -9681,6 +9681,11 @@ private: bool bNewChecked = gtk_widget_get_state_flags(GTK_WIDGET(pToggleButton)) & GTK_STATE_FLAG_CHECKED; if (bOldChecked == bNewChecked) return; + if (bOldChecked && gtk_widget_get_focus_on_click(GTK_WIDGET(pToggleButton))) + { + // grab focus back to the toggle button if the menu was popped down + gtk_widget_grab_focus(GTK_WIDGET(pToggleButton)); + } SolarMutexGuard aGuard; pThis->signal_toggled(); } @@ -9828,7 +9833,17 @@ public: return *m_xFont; return GtkInstanceWidget::get_font(); } - +#else + virtual void set_active(bool bActive) override + { + bool bWasActive = get_active(); + GtkInstanceToggleButton::set_active(bActive); + if (bWasActive && !bActive && gtk_widget_get_focus_on_click(GTK_WIDGET(m_pMenuButton))) + { + // grab focus back to the toggle button if the menu was popped down + gtk_widget_grab_focus(GTK_WIDGET(m_pMenuButton)); + } + } #endif virtual void insert_item(int pos, const OUString& rId, const OUString& rStr, |