# Extarcting sring from a dropdown doesnt work like it should

**URL:** <http://forum.squareline.io/t/extarcting-sring-from-a-dropdown-doesnt-work-like-it-should/2961>\
**Category:** How to\
**Created:** [May 28, 2024, 5:05pm UTC](http://forum.squareline.io/t/extarcting-sring-from-a-dropdown-doesnt-work-like-it-should/2961 "2024-05-28T17:05:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahmoud12](http://forum.squareline.io/letter_avatar_proxy/v4/letter/m/57b2e6/32.png) [@mahmoud12](http://forum.squareline.io/u/mahmoud12)\
**Post date:** [May 28, 2024, 5:05pm UTC](http://forum.squareline.io/t/extarcting-sring-from-a-dropdown-doesnt-work-like-it-should/2961/1 "2024-05-28T17:05:27Z")

</div>

### What do you want to achieve?

i would like to be able extract a string form a dropdown list from first click.

### What have you tried so far?

I have successfully extracted a string from a dropdown list, my problem is that i have to click the widget again for the extraction to work.

  
This is the function i wrote to handle the dropdown list event:

```auto
static void event_cb(lv_event_t * e)
{
    lv_event_code_t code = lv_event_get_code(e);
    lv_obj_t *obj = lv_event_get_target(e);
    char buf[64];
    if (code == LV_EVENT_RELEASED){
    //lv_obj_clear_flag(ui_Keyboard2, LV_OBJ_FLAG_HIDDEN);
     //lv_obj_clear_flag(ui_Panel1, LV_OBJ_FLAG_HIDDEN);
    lv_dropdown_get_selected_str(ui_TESTDROP, buf, sizeof(buf));
     String selectedItem =String (buf);
     dd=selectedItem;
    for (int i = 0; i < selectedItem.length() - 1; i++) {
      if (selectedItem.substring(i, i + 2) != " (") {
        ssidName = dd;
       lv_label_set_text_fmt(ui_Label5, "%s", ssidName);
        break;
      }
    }
  }

```

and another bug that i couldn’t solve was why does the function automatically extracts he first option on the list, is there a possible solution for this??

### Others

- \*\*SquareLine Studio version: 1.4.0
- **Operating system:**
- **Target hardware:**

---

<div class="post-metadata">

**Author:** ![Hermit](http://forum.squareline.io/user_avatar/forum.squareline.io/hermit/32/971_2.png) [@Hermit](http://forum.squareline.io/u/Hermit)\
**Post date:** [May 29, 2024, 2:34pm UTC](http://forum.squareline.io/t/extarcting-sring-from-a-dropdown-doesnt-work-like-it-should/2961/2 "2024-05-29T14:34:01Z")

</div>

I think you should simply use the VALUE\_CHANGED trigger instead of the RELEASED.  
(And to init the dropdown-widget with a specific index, not always the first, you can use `lv_dropdown_set_selected(dropdown_widget,index)` in the SCREEN\_LOADED event when opening its screen.)
