Define button label from entered text from text area

What do you want to achieve?

Make a button where user can change the label text in order to customize it…

What have you tried so far?

Use a text area and make it clickable, detect when clicked then keyboard changes state from hidden then enter text that way but cannot figure out how to “move” that text over to the button label. I know it can be done in code but it would be nice to make it work in Squareline…

Screenshot or video

Others

  • **SquareLine Studio version: Latest
  • Operating system:
  • **Target hardware: ESP32

You need to add a change event on the textarea that calls a custom function. That function would copy the value of the textarea to the label.

You can’t do that exact task directly in SquareLine Studio currently, but manually in the exported code like CodeGrue says, with a CALL_FUNCTION event on the READY trigger of the used keyboard-widget. (If you set ‘Don’t export’ for the event, the function can (and must) be in your own code, otherwise you’ll find the function in ui_events.c, where you can get the text of the edited textfield with lv_textarea_get_text() and copy it to the button-label with lv_label_set_text().)
(Btw you can set fix text in SquareLine studio by choosing ‘change property’ for ‘label’ event, placing it on a ‘READY’ trigger of your keyboard-widget, which triggers the label-change event on the button. But it seems that’s not what you want.)
Another option might be to add the textarea directly inside your button-object in the hierarchy, with a styling that fits the button, with clickable flag turned off (so the button’s whole area including the textarea, is clickable), then assigning that textarea inside the button to the keyboard. You can set it on the ‘VALUE_CHANGED’ trigger of the keyboard to update instantly or on the ‘READY’ trigger to update it by the tick.