How to receive drag-direction of the fixed-position object in easy way?


I create an object that I don’t want to move it.
When a user is touching over the object,
how can I receive the object’s touch-direction such as drag up/down/left/right
in easy way?

Thank you.

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

  • ESP32

What do you want to achieve?

  • Get the touching direction of the object.

What have you tried so far?

I tried by set a event_cb function but I can’t receive LV_EVENT_DRAG_BEGIN
or something about drag-information.

Code to reproduce

Screenshot and/or video

If drag is not enabled by lv_obj_set_drag(obj, true) none of the drag related things will be executed (e.g. no drag events are sent).

You can do this to see the change in press position:

void event_handler(lv_obj_t * obj, lv_event_t event)
    if(event == LV_EVENT_PRESSING) {
        lv_indev_t * indev = lv_indev_get_act();
        printf("x:%d, y:%d\n", indev->proc.types.pointer.vect.x, indev->proc.types.pointer.vect.y);

1 Like

Thank you.