mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
Merge branch 'fix-custom-widget-menu-focus' into 'master'
menusectionbox: Passthrough the focus function of custom widgets' gizmo Closes gnome-text-editor#93 See merge request GNOME/gtk!3817
This commit is contained in:
commit
5df323fb64
@ -309,6 +309,25 @@ submenu_hidden (GtkPopoverMenu *popover,
|
||||
gtk_menu_tracker_item_request_submenu_shown (item, FALSE);
|
||||
}
|
||||
|
||||
/* We're using the gizmo as an easy single child container, not as
|
||||
* a custom widget to draw some visual indicators (like markers).
|
||||
* As such its default focus functions blocks focus through the children,
|
||||
* so we need to handle it correctly here so that custom widgets inside
|
||||
* menus can be focused.
|
||||
*/
|
||||
static gboolean
|
||||
custom_widget_focus (GtkGizmo *gizmo,
|
||||
GtkDirectionType direction)
|
||||
{
|
||||
return gtk_widget_focus_child (GTK_WIDGET (gizmo), direction);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
custom_widget_grab_focus (GtkGizmo *gizmo)
|
||||
{
|
||||
return gtk_widget_grab_focus_child (GTK_WIDGET (gizmo));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_menu_section_box_insert_func (GtkMenuTrackerItem *item,
|
||||
int position,
|
||||
@ -369,7 +388,7 @@ gtk_menu_section_box_insert_func (GtkMenuTrackerItem *item,
|
||||
{
|
||||
const char *id = gtk_menu_tracker_item_get_custom (item);
|
||||
|
||||
widget = gtk_gizmo_new ("widget", NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
widget = gtk_gizmo_new ("widget", NULL, NULL, NULL, NULL, custom_widget_focus, custom_widget_grab_focus);
|
||||
gtk_widget_set_layout_manager (widget, gtk_bin_layout_new ());
|
||||
|
||||
if (g_hash_table_lookup (box->custom_slots, id))
|
||||
|
Loading…
Reference in New Issue
Block a user