Object order within group

Description

Is there a functionality where after removing an object from a group, when re-adding the object it is added within relation to another object?

Example:
(Assuming default group)

Current Behavior:

  • Original Group order:
    Obj_A → Obj_B → Obj_C → Obj_D
  • Remove Obj_B from group:
    lv_group_remove_obj(Obj_B);
  • Re-add Obj_B to group:
    lv_group_add_obj(lv_group_get_default, Obj_B);
  • New group order
    Obj_A ->Obj_C → Obj_D → Obj_B

Desired/Future Behavior:

  • Original Group order:
    Obj_A → Obj_B → Obj_C → Obj_D
  • Remove Obj_B from group:
    lv_group_remove_obj(Obj_B);
  • Re-add Obj_B to group:
    lv_group_add_obj(lv_group_get_default, Obj_B, Obj_A);
  • New group order
    Obj_A → Obj_B → Obj_C → Obj_D

What LVGL version are you using?

v8.3.10

Do you think this is something that can be added? Currently, the only way I have been able to archive the proper order again is to re-add all obj within the group

Use lv_obj_set_parent to change parent object:
https://docs.lvgl.io/master/API/core/lv_obj_tree.html#_CPPv417lv_obj_set_parentP9_lv_obj_tP9_lv_obj_t

Use lv_obj_move_to_index to adjust the order of child objects:
https://docs.lvgl.io/master/API/core/lv_obj_tree.html#_CPPv420lv_obj_move_to_indexP9_lv_obj_t7int32_t

@FASTSHIFT your reply is complete out of Q

I mean group for indev can be only recreated
lv_group_remove_all_objs (lv_group_t*group )
and add all in new order.

As @mmar22 mentioned this only takes care of the “screen” order, but not within the group.

The remove all → re-add all approach does work, but a lv_group_move_to_index like function would be ideal! I’ll see if that is something I can work on.

Both move to index or readd is unnefective. Effective is only dont remove objects from groups and mark it not focusable or somethink that skip indev…

Removing from the group is what skips it as we discussed here: Encoder: How to make object not "focused" - #7 by kisvegabor