# Handling custom events - possible?

**URL:** <http://forum.squareline.io/t/handling-custom-events-possible/2308>\
**Category:** Uncategorized\
**Created:** [January 2, 2024, 1:47pm UTC](http://forum.squareline.io/t/handling-custom-events-possible/2308 "2024-01-02T13:47:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![haberlerm](http://forum.squareline.io/letter_avatar_proxy/v4/letter/h/eb9ed0/32.png) [@haberlerm](http://forum.squareline.io/u/haberlerm)\
**Post date:** [January 2, 2024, 1:47pm UTC](http://forum.squareline.io/t/handling-custom-events-possible/2308/1 "2024-01-02T13:47:24Z")

</div>

Assume I define [custom events](https://docs.lvgl.io/8.3/overview/event.html#custom-events)

is there a way to add such a custom event name to an event handler?

Michael

---

<div class="post-metadata">

**Author:** ![Marian\_M](http://forum.squareline.io/letter_avatar_proxy/v4/letter/m/4af34b/32.png) [@Marian\_M](http://forum.squareline.io/u/Marian_M)\
**Post date:** [January 2, 2024, 2:35pm UTC](http://forum.squareline.io/t/handling-custom-events-possible/2308/2 "2024-01-02T14:35:41Z")

</div>

In actual Squareline no, but you have user 1…4 states and styles here  
 ![image](http://forum.squareline.io/uploads/default/original/2X/7/77d62bbd5874dc01848d22c7691a1d27a3497d9e.png)

your custom event require only in your code handlers.

---

<div class="post-metadata">

**Author:** ![haberlerm](http://forum.squareline.io/letter_avatar_proxy/v4/letter/h/eb9ed0/32.png) [@haberlerm](http://forum.squareline.io/u/haberlerm)\
**Post date:** [January 2, 2024, 2:58pm UTC](http://forum.squareline.io/t/handling-custom-events-possible/2308/3 "2024-01-02T14:58:32Z")

</div>

I have a custom event source (NFC read events) and I want to cause a custom function to be called when that happens

not sure I understand what you are proposing?

Michael

---

<div class="post-metadata">

**Author:** ![Marian\_M](http://forum.squareline.io/letter_avatar_proxy/v4/letter/m/4af34b/32.png) [@Marian\_M](http://forum.squareline.io/u/Marian_M)\
**Post date:** [January 2, 2024, 3:18pm UTC](http://forum.squareline.io/t/handling-custom-events-possible/2308/4 "2024-01-02T15:18:14Z")

</div>

Then you ask bad question. LVGL custom events is designed for send to lv objects nothing more. When you require only reaction to slow events use loop or lv\_timer pooling . But this isnt squareline job.

---

<div class="post-metadata">

**Author:** ![haberlerm](http://forum.squareline.io/letter_avatar_proxy/v4/letter/h/eb9ed0/32.png) [@haberlerm](http://forum.squareline.io/u/haberlerm)\
**Post date:** [January 3, 2024, 5:25am UTC](http://forum.squareline.io/t/handling-custom-events-possible/2308/5 "2024-01-03T05:25:02Z")

</div>

fair enough - then: how would you do this?

I already translate the NFC events into key events through a pseudo keypad indev, and that works fine for instance if a text area with focus is active

I’d rather have a custom handler be called on the current screen though

happy to take suggestions

Michael

---

<div class="post-metadata">

**Author:** ![Marian\_M](http://forum.squareline.io/letter_avatar_proxy/v4/letter/m/4af34b/32.png) [@Marian\_M](http://forum.squareline.io/u/Marian_M)\
**Post date:** [January 3, 2024, 8:34am UTC](http://forum.squareline.io/t/handling-custom-events-possible/2308/6 "2024-01-03T08:34:53Z")

</div>

You lack info then hard to suggest, but simple any indev is handled in lv loop timed handler. Then create keypad is little hardcore, when your NFC isnt keypad.

For example NFC create max two events per second.  
You create hw based func or task for read data and store in memory.

```auto
void NFCreader()
{
store data ...
set newdatareaded=true;

```

```auto
void NFCguiupdate(lv_timer_t * timer)
{
if(newdatareaded && lv_scr_act()==...) {
show what required
newdatareaded=false;
}
}

in screen or app load
lv_timer_t * timer = lv_timer_create(NFCguiupdate, 500, NULL);

```
