diff --git a/gtk/gtkmenusectionbox.c b/gtk/gtkmenusectionbox.c index 89f01d3d6a..6d3251e341 100644 --- a/gtk/gtkmenusectionbox.c +++ b/gtk/gtkmenusectionbox.c @@ -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))