Tabview Page Events Squareline Studio ver. 1.4

Hello,

I want to add an event when only a specific page button is “clicked” in a tabview widget. I tried the “Clicked” event for the specific page of the tabview widget but it does not seem to work in SLS. For example I want to change the screen when this particular tab page button is pressed. Is it possible to do it in SLS ?

If you want to solve it in SquareLine Studio without any coding involved you can place a container or button over the tab-button (by placing it lower in the hierarchy panel) and create event-action for that. The tabview-button behind it won’t be active and change a tab, but the button/panel placed above it will create the action. (Other methods like assigning CLICKED/FOCUSED on the tab-pages or their content doesn’t seem to work the way you wish.)

This is a workaround but the best solution can be reached by creating custom actions for that specific tabview-button, so for instance styling and resizing won’t cause issues. You can’t create individual events for them, but if in SquareLine Studio you add an event to the tabview widget for a VALUE_CHANGED trigger and a CALL_FUNCTION action (specifying function-name), later in your code you can distinguish the pressed tabview button by e.g. lv_tabview_get_tab_act( ui_TabView1 ) in the event handler. Corresponding LVGL document: Tabview (lv_tabview) — LVGL documentation (‘Events’ section)

Another completely LVGL-code based alternative might be creating the event only for the buttonmatrix that’s created by LVGL under the hood for the tabview complex widget ( with e.g. lv_tabview_get_tab_btns( ui_TabView1 ) ) and adding LV_VALUE_CHANGED event to the button-matrix, then inside that event you can get the pressed button’s ID by lv_btnmatrix_get_selected_btn() function to decide if custom action is to be taken. (LVGL docs about button-matrix: Button matrix (lv_btnmatrix) — LVGL documentation , see Events section here too.)

(Hopefully it’s not a problem for you if the button changes tab-page by default at the same time.)

1 Like

The 2 solutions you suggested in SLS work for me, thanks

1 Like

Great to hear that the proposed solution works for you.