1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00
lvgl/examples/widgets/obj/lv_example_obj_2.py
bjsylvia 67ca457a07
fix: fix typos (#4451)
Signed-off-by: XiaoweiYan <yanxiaowei@xiaomi.com>
Co-authored-by: XiaoweiYan <yanxiaowei@xiaomi.com>
2023-08-14 16:49:30 +02:00

26 lines
428 B
Python

def drag_event_handler(e):
obj = e.get_target_obj()
indev = lv.indev_get_act()
vect = lv.point_t()
indev.get_vect(vect)
x = obj.get_x() + vect.x
y = obj.get_y() + vect.y
obj.set_pos(x, y)
#
# Make an object draggable.
#
obj = lv.obj(lv.scr_act())
obj.set_size(150, 100)
obj.add_event(drag_event_handler, lv.EVENT.PRESSING, None)
label = lv.label(obj)
label.set_text("Drag me")
label.center()