Description
I want to be able to know the state an object in text. I did not check if there is any function that returns the state as text and not only by the default value so i have created a simple function with a switch to do it.
By watching the struct there is question about the ORed states. What is the translation of status of 0x0010 . Is it only HOVERED or EDITED + FOCUSED
What MCU/Processor/Board and compiler are you using?
esp32,simulator
What LVGL version are you using?
8.3
What do you want to achieve?
To be able to identify the text. Some of the values of the enum if agregated the fall into other values that are not for the same reason
What have you tried so far?
Tried to create a function that calls the get state function for an event and return proper text that describes the current state by trying to answer also for the ORed states.
When i select a text area i get a state with value 34 which could be either:
- LV_STATE_PRESSED | LV_STATE_HOVERED | LV_STATE_FOCUS_KEY
- LV_STATE_PRESSED | LV_STATE_EDITED | LV_STATE_FOCUS_KEY | LV_STATE_FOCUSED
I assume it is the first but ok it is still not clear.
Is there a proper way to identify that i have missed ? Something already existing?
Code to reproduce
// this is the default states from lvgl
enum {
LV_STATE_DEFAULT = 0x0000,
LV_STATE_CHECKED = 0x0001,
LV_STATE_FOCUSED = 0x0002,
LV_STATE_FOCUS_KEY = 0x0004,
LV_STATE_EDITED = 0x0008,
LV_STATE_HOVERED = 0x0010,
LV_STATE_PRESSED = 0x0020,
LV_STATE_SCROLLED = 0x0040,
LV_STATE_DISABLED = 0x0080,
LV_STATE_USER_1 = 0x1000,
LV_STATE_USER_2 = 0x2000,
LV_STATE_USER_3 = 0x4000,
LV_STATE_USER_4 = 0x8000,
LV_STATE_ANY = 0xFFFF, /**< Special value can be used in some functions to target all states*/
};
typedef uint16_t lv_state_t;
//and what i did
char* str_get_obj_state(lv_obj_t* obj){
lv_state_t state=lv_obj_get_state(obj);
switch(state){
case 0x0000:
return "LV_STATE_DEFAULT";
break;
case 0x0001:
return "LV_STATE_CHECKED";
break;
case 0x0002:
return "LV_STATE_FOCUSED";
break;
case 0x0003:
return "LV_STATE_CHECKED & LV_STATE_FOCUSED";
break;
case 0x0004:
return "LV_STATE_FOCUS_KEY";
break;
case 0x0005:
return "LV_STATE_CHECKED & LV_STATE_FOCUS_KEY";
break;
case 0x0006:
return "LV_STATE_FOCUSED & LV_STATE_FOCUS_KEY";
break;
case 0x0007:
return "LV_STATE_CHECKED & LV_STATE_FOCUSED & LV_STATE_FOCUS_KEY";
break;
case 0x0008:
return "LV_STATE_EDITED";
break;
case 0x0009:
return "LV_STATE_CHECKED & LV_STATE_EDITED";
break;
case 0x0010:
return "LV_STATE_HOVERED"; // this could also be EDITED+FOCUSED
break;
default:
LV_LOG_USER("unIdentified state: %d",state);
return "Will check the rest";
break;
}
return "";
}