I want to filter in the event routine of a textarea to determine the object name of the ta that fired the event so I can use the same event handler for multiple ta’s.
What is the correct syntax to the the object name?
Here is my example if(ta.objectname() == ta1) do something
This does not seem to work, looking for the correct syntax.
lv_obj_type_t buf;
lv_obj_get_type(obj, &buf);
uint8_t i = 0;
while(buf.type[i] != NULL) {
if(!strcmp(buf.type[i], "lv_textarea")) { /* use lv_ta for 6.1 and under */
/* It inherits from a text area*/
}
i++;
}
Well, I think there is some confusion here. What I really need is the name of the textarea.
For my application I have 2 textareas each with a different name, i.e. ta1 and ta2.
In the event handler I need to filter on which specific textarea fired the event, either ta1 or ta2.
Getting the object type won’t distinguish which textarea the event was fired.
Whoops… I misunderstood what you wanted. I thought you were trying to distinguish types of objects. If you are trying to determine which object, then this is much easier. Just keep the object reference in a global variable and compare it to the one passed to the event handler.
Hi,
I would like to try this solution, but how do we use lv_obj_add_event_cb() for adding an event function with 2 arguments lv_obj_t * obj and lv_event_t event ?
If I try to add an event with two arguments, I have an error.