# Adding button Events to Gui (lvgl 8.3.6)

**URL:** <http://forum.squareline.io/t/adding-button-events-to-gui-lvgl-8-3-6/2545>\
**Category:** How to\
**Created:** [February 15, 2024, 1:51pm UTC](http://forum.squareline.io/t/adding-button-events-to-gui-lvgl-8-3-6/2545 "2024-02-15T13:51:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pee123](http://forum.squareline.io/letter_avatar_proxy/v4/letter/p/f9ae1b/32.png) [@Pee123](http://forum.squareline.io/u/Pee123)\
**Post date:** [February 15, 2024, 1:51pm UTC](http://forum.squareline.io/t/adding-button-events-to-gui-lvgl-8-3-6/2545/1 "2024-02-15T13:51:23Z")

</div>

Hi, I am trying to get events to work on a simple project by force sending a keypad click (LV\_KEY\_RIGHT) to the indev function as below:-

_void lv\_port\_indev\_init(void)_  
_{_

- keypad\_init();\*

- lv\_indev\_drv\_init(&indev\_drv);\*

- indev\_drv.type = LV\_INDEV\_TYPE\_KEYPAD;\*

- indev\_drv.read\_cb = keypad\_read;\*

- indev\_keypad = lv\_indev\_drv\_register(&indev\_drv);\*

_}_

_static void keypad\_read(lv\_indev\_drv\_t \* indev\_drv, lv\_indev\_data\_t \* data)_

_{_  
_data-\>state = LV\_INDEV\_STATE\_PR;_  
_data-\>key = LV\_KEY\_RIGHT;_  
_}_

I have then made a simple ui in squareline with 2 buttons with 2 events (event trigger is on the back panel itself) from which the 2nd button should change state to pressed when “LV\_KEY\_RIGHT” is called, but the screen just sits there and doesn’t change state? I have also tried force sending “_lv\_event\_send(&ui\_Panel2, LV\_KEY\_RIGHT , NULL);_” and “lv\_event\_send(&ui\_Button2, LV\_STATE\_PRESSED , NULL);” which still doesn’t change the button state? I am at a loss on how to get input driven events to work on the ui?

---

<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:** [February 22, 2024, 2:07pm UTC](http://forum.squareline.io/t/adding-button-events-to-gui-lvgl-8-3-6/2545/2 "2024-02-22T14:07:07Z")

</div>

Have you added the indev to the default group (created with `lv_group_t * g = lv_group_create()` and `lv_group_set_default(g)` ) with the call `lv_ivdev_set_group( indev_keypad, g)` ?  
Note: If you send a state-setting LVGL event to a widget it won’t necessarily cause the assigned event as if it was pressed by hand.)
