I want to ask you how to move the control freely in the lvgl screen

What do you want to achieve?

I want to move the position of the keyboard in the lvgl screen, what to do, can you provide an example for a reference?

What have you tried so far?

This is my own code but it does not implement to make the keyboard position move at will:

static void ta_event_cb(lv_event_t * e)
{
lv_obj_t * obj = lv_event_get_target(e);

lv_indev_t * indev = lv_indev_get_act();
if(indev == NULL)  return;

lv_point_t vect;
lv_indev_get_vect(indev, &vect);

lv_coord_t x = lv_obj_get_x(obj) + vect.x;
lv_coord_t y = lv_obj_get_y(obj) + vect.y;
lv_obj_set_pos(obj, x, y);

}

void lv_example_keyboard_1(void)
{
lv_obj_t * obj;
obj = lv_obj_create(lv_scr_act());
lv_obj_set_size(obj, 150, 100);

lv_obj_t * kb = lv_keyboard_create(lv_scr_act());

lv_obj_add_event_cb(kb,ta_event_cb, LV_EVENT_PRESSING, NULL);

}

Others

  • **SquareLine Studio version:8.3.11
  • **Operating system:rt-thread
  • **Target hardware:stm32f407zgt6