This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository efl.

View the commit online.

commit 2ceadfb040719546cfecc51fa00c739644170912
Author: Cedric BAIL <[email protected]>
AuthorDate: Mon Oct 26 15:25:17 2026 -0600

    elementary: tab goes through a box's children in packing order
    
    The focus manager keeps a node's children in the order it hears of them,
    unless the node gives it an order. Efl.Ui.Box never did, and it hears of
    a box's children as each one is shown -- which, when a window shows them
    all at once, is the reverse of the order they were packed in. A box of
    buttons A, B and C was tabbed through as C, B, A; a list packed between
    two buttons came after the one below it, so Shift+Tab from that button
    never reached the list.
    
    The manager asks a node for its order, through setup_order, before going
    through its children. The box now answers with its children in the
    order they are packed, which also follows pack_begin, pack_before and
    the like.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/lib/elementary/efl_ui_box.c         | 13 +++++++++++++
 src/lib/elementary/efl_ui_box.eo        |  1 +
 src/lib/elementary/efl_ui_box_private.h |  1 +
 src/tests/elementary/efl_ui_test_box.c  | 22 ++++++++++++++++++++++
 4 files changed, 37 insertions(+)

diff --git a/src/lib/elementary/efl_ui_box.c b/src/lib/elementary/efl_ui_box.c
index 4f3b29f068..34cc5a79f0 100644
--- a/src/lib/elementary/efl_ui_box.c
+++ b/src/lib/elementary/efl_ui_box.c
@@ -213,6 +213,19 @@ _efl_ui_box_efl_container_content_count(Eo *obj EINA_UNUSED, Efl_Ui_Box_Data *pd
    return eina_list_count(pd->children);
 }
 
+/* The focus manager orders the children of a node as it hears of them, and
+   it hears of a box's children as each is shown, in no order the box
+   controls. Tab goes through them in the order they are packed in. */
+EOLIAN static void
+_efl_ui_box_efl_ui_focus_object_setup_order_non_recursive(Eo *obj, Efl_Ui_Box_Data *pd)
+{
+   Efl_Ui_Focus_Manager *manager = efl_ui_focus_object_focus_manager_get(obj);
+
+   if (manager && pd->children)
+     efl_ui_focus_manager_calc_update_order(manager, obj, eina_list_clone(pd->children));
+   efl_ui_focus_object_setup_order_non_recursive(efl_super(obj, MY_CLASS));
+}
+
 EOLIAN static Eina_Bool
 _efl_ui_box_efl_pack_pack_clear(Eo *obj, Efl_Ui_Box_Data *pd)
 {
diff --git a/src/lib/elementary/efl_ui_box.eo b/src/lib/elementary/efl_ui_box.eo
index a8b8f23b4b..9d004af05d 100644
--- a/src/lib/elementary/efl_ui_box.eo
+++ b/src/lib/elementary/efl_ui_box.eo
@@ -45,6 +45,7 @@ class Efl.Ui.Box extends Efl.Ui.Widget implements Efl.Pack_Linear, Efl.Pack_Layo
       Efl.Gfx.Entity.size { set; }
       Efl.Container.content_iterate;
       Efl.Container.content_count;
+      Efl.Ui.Focus.Object.setup_order_non_recursive;
       Efl.Ui.Layout_Orientable.orientation { get; set; }
       Efl.Pack.pack_clear;
       Efl.Pack.unpack_all;
diff --git a/src/lib/elementary/efl_ui_box_private.h b/src/lib/elementary/efl_ui_box_private.h
index bc9fca1d47..025128db1f 100644
--- a/src/lib/elementary/efl_ui_box_private.h
+++ b/src/lib/elementary/efl_ui_box_private.h
@@ -6,6 +6,7 @@
 #endif
 
 #define EFL_PACK_LAYOUT_PROTECTED
+#define EFL_UI_FOCUS_OBJECT_PROTECTED
 
 #include <Elementary.h>
 #include "elm_priv.h"
diff --git a/src/tests/elementary/efl_ui_test_box.c b/src/tests/elementary/efl_ui_test_box.c
index 7b8aa25380..eb5f18f143 100644
--- a/src/tests/elementary/efl_ui_test_box.c
+++ b/src/tests/elementary/efl_ui_test_box.c
@@ -559,6 +559,27 @@ EFL_START_TEST (efl_ui_box_internal)
 }
 EFL_END_TEST
 
+/* Tab goes through a box's children in the order they are packed in, not
+   the order the focus manager happened to hear of them -- which, as they
+   are all shown at once, is the reverse. */
+EFL_START_TEST (efl_ui_box_focus_order)
+{
+   Eo *a, *b, *c;
+
+   efl_content_set(win, layout);
+   a = efl_add(EFL_UI_BUTTON_CLASS, layout, efl_pack_end(layout, efl_added));
+   b = efl_add(EFL_UI_BUTTON_CLASS, layout, efl_pack_end(layout, efl_added));
+   c = efl_add(EFL_UI_BUTTON_CLASS, layout, efl_pack_begin(layout, efl_added));
+   get_me_to_those_events(win);
+
+   efl_ui_focus_util_focus(c);
+   ck_assert_ptr_eq(efl_ui_focus_manager_move(win, EFL_UI_FOCUS_DIRECTION_NEXT), a);
+   ck_assert_ptr_eq(efl_ui_focus_manager_move(win, EFL_UI_FOCUS_DIRECTION_NEXT), b);
+   ck_assert_ptr_eq(efl_ui_focus_manager_move(win, EFL_UI_FOCUS_DIRECTION_PREVIOUS), a);
+   ck_assert_ptr_eq(efl_ui_focus_manager_move(win, EFL_UI_FOCUS_DIRECTION_PREVIOUS), c);
+}
+EFL_END_TEST
+
 void efl_ui_test_box(TCase *tc)
 {
    tcase_add_checked_fixture(tc, layout_setup, NULL);
@@ -569,4 +590,5 @@ void efl_ui_test_box(TCase *tc)
    tcase_add_test(tc, efl_ui_box_pack_unpack);
    tcase_add_test(tc, efl_ui_box_properties);
    tcase_add_test(tc, efl_ui_box_internal);
+   tcase_add_test(tc, efl_ui_box_focus_order);
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to