What do you want to achieve?
i want to be able to extract a string on drop down list and save it to a variable
What have you tried so far?
i tried using the following code segment but it doesn’t work
char test[32]={0};
lv_dropdown_get_selected_str(ui_TESTDROP,test,32);
Serial.printf("\n\n%c\n\n",test);
Screenshot or video
Others
-
SquareLine Studio version:
1.4.0
-
Operating system:
win11
- Target hardware:
This might help
static void event_cb(lv_event_t * e)
{
lv_obj_t * dropdown = lv_event_get_target(e);
char buf[64];
lv_dropdown_get_selected_str(dropdown, buf, sizeof(buf));
LV_LOG_USER("'%s' is selected", buf);
}
This did not work for me , thank you for the reply
This lv_dropdown_get_selected_str( dropdown_widget, target_string, length ) should work, I used it many times. Maybe using global/static target_string helps if you (or Serial.printf()) want to use the result later, just a tip. As sprad001 says, you should use it in a callback set to the dropdown’s VALUE_CHANGED event. You can do it without the lv_event_get_target() and giving the dropdown_widget pointer directly, as a test.
But if you specify what the problem exactly is we might be able to give more specific help.