How to differentiate click event and long press event


I have a button that needs to perform two events, this button is a toggle button when clicked, and switches pages when long pressed. The problem encountered is that when you press and hold, the clicked event is also triggered. How to avoid it?

What MCU/Processor/Board and compiler are you using?


What LVGL version are you using?


Can someone solve my problem?thanks.

void my_event_cb(lv_event_t *e) {
	lv_indev_t *indev = lv_event_get_indev(e);
	if(indev->proc.long_pr_sent) {
		puts("Long Press");
	} else {
1 Like

LV_EVENT_SHORT_CLICKED can be used too.

1 Like

Thanks a lot for your reply, I’ll give it a try.

OK, received, thank you very much.