Can i find out what type of object has focus in a group


What MCU/Processor/Board and compiler are you using?

I am using the simulator and the stm32

What LVGL version are you using?

Version 6.1.2

What do you want to achieve?

When i retreive the focused object from a group using *“lv_group_get_focused”, i get an object back. Is there any way to tell what type of object this is? e.g. Is it a button or is it a switch?

What have you tried so far?

At the moment i have kept an array of objects that are in the group. I do a comparison between each object in that array and the object that i retreive from the “lv_group_get_focused” function, I then do a comparison between them all to find which one has focus.

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

//pseudo code of what i am doing
int indexFound=0;
for(int x=0;x<SizeOfObjectArray;x++)

//pseudo code of what i would like to be able to do
lv_obj_t* obj = =lv_group_get_focused(group);
switch (obj.type)

Hi @sambuddy200471,

You could create an array of structures instead maybe and an enum of types? Something along these lines:

enum {
typedef uint8_t obj_types_t;

struct obj_list {
    lv_obj_t       *obj;
    obj_types_t    type;

When you create the objects save them in the array with the type also and then switch on the obj_list.type value.

I don’t know if that helps?

Kind Regards,


You can use lv_obj_get_type.

thanks for that. Its amazing how many times you can read the documentation…and still miss what you are looking for