# The keyboard plug-in for lvgl moves in any position on the screen

**URL:** <http://forum.squareline.io/t/the-keyboard-plug-in-for-lvgl-moves-in-any-position-on-the-screen/3824>\
**Category:** How to\
**Tags:** lvgl\
**Created:** [September 19, 2024, 3:33am UTC](http://forum.squareline.io/t/the-keyboard-plug-in-for-lvgl-moves-in-any-position-on-the-screen/3824 "2024-09-19T03:33:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunboy](http://forum.squareline.io/letter_avatar_proxy/v4/letter/s/e19b73/32.png) [@sunboy](http://forum.squareline.io/u/sunboy)\
**Post date:** [September 19, 2024, 3:33am UTC](http://forum.squareline.io/t/the-keyboard-plug-in-for-lvgl-moves-in-any-position-on-the-screen/3824/1 "2024-09-19T03:33:49Z")

</div>

### What do you want to achieve?

I want to ask, what is the way to move the lvgl’s keyboard in the screen?

### What have you tried so far?

I used the following method, but I can’t use the keyboard plug-in on the squareline. Once I move the keyboard, I don’t know where to go.

static void drag\_event\_handler(lv\_event\_t\* e)  
{  
lv\_obj\_t\* obj = lv\_event\_get\_target(e);  
lv\_indev\_t\* indev = lv\_indev\_get\_act();  
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);  
}

 ![1726716266197](http://forum.squareline.io/uploads/default/original/2X/3/33abce3b9489e52c5cbb801df717fd7e2e9473e6.png)

### Others

- \*\*SquareLine Studio version:1.4.1
- \*\*Operating system:rt-thread
- \*\*Target hardware:stm32f407zgt6

---

<div class="post-metadata">

**Author:** ![Hermit](http://forum.squareline.io/user_avatar/forum.squareline.io/hermit/32/971_2.png) [@Hermit](http://forum.squareline.io/u/Hermit)\
**Post date:** [September 19, 2024, 7:14am UTC](http://forum.squareline.io/t/the-keyboard-plug-in-for-lvgl-moves-in-any-position-on-the-screen/3824/2 "2024-09-19T07:14:56Z")

</div>

It’s not quite clear from the description what your exact problem is, but I think it’s better to use absolute coordinates instead of movement vectors for this, so possible accumulated misalignments can be prevented. At least it’s worth a try with lv\_indev\_get\_point() function if it serves your purpose better.

---

<div class="post-metadata">

**Author:** ![sunboy](http://forum.squareline.io/letter_avatar_proxy/v4/letter/s/e19b73/32.png) [@sunboy](http://forum.squareline.io/u/sunboy)\
**Post date:** [September 19, 2024, 8:47am UTC](http://forum.squareline.io/t/the-keyboard-plug-in-for-lvgl-moves-in-any-position-on-the-screen/3824/3 "2024-09-19T08:47:51Z")

</div>

As soon as I touch the keyboard and prepare to move the keyboard, the keyboard disappears in the picture, and I can’t see the keyboard.Use the same function result as you provide (lv\_indev\_get\_point(indev, &vect)).  
The picture becomes the following appearance:

 ![1726735587072](http://forum.squareline.io/uploads/default/original/2X/4/42b02a030c16d537c8e98c129e2356bf3ade6457.png)

---

<div class="post-metadata">

**Author:** ![Hermit](http://forum.squareline.io/user_avatar/forum.squareline.io/hermit/32/971_2.png) [@Hermit](http://forum.squareline.io/u/Hermit)\
**Post date:** [September 23, 2024, 8:34am UTC](http://forum.squareline.io/t/the-keyboard-plug-in-for-lvgl-moves-in-any-position-on-the-screen/3824/4 "2024-09-23T08:34:58Z")

</div>

It should work, but you still need to calculate the middle of the keyboard from its size, and subtract it from the indev-coordinates before applying them to the keyboard (if you want to move with its middle, but a surrounding inactive button-less area would be better for clean grabbing).  
With a printf() you can check if the coordinates from the indev are coming correctly at all. Also you can reprocess the received coordinate-values by LV\_CLAMP function to always stay in the screen, even if the indev coordinates are negative or out of screen…

---

<div class="post-metadata">

**Author:** ![sunboy](http://forum.squareline.io/letter_avatar_proxy/v4/letter/s/e19b73/32.png) [@sunboy](http://forum.squareline.io/u/sunboy)\
**Post date:** [September 24, 2024, 1:46am UTC](http://forum.squareline.io/t/the-keyboard-plug-in-for-lvgl-moves-in-any-position-on-the-screen/3824/5 "2024-09-24T01:46:20Z")

</div>

"LV \_ CLAMP " This function “lvgl V8.3” seems to have no.

---

<div class="post-metadata">

**Author:** ![Hermit](http://forum.squareline.io/user_avatar/forum.squareline.io/hermit/32/971_2.png) [@Hermit](http://forum.squareline.io/u/Hermit)\
**Post date:** [September 24, 2024, 6:18am UTC](http://forum.squareline.io/t/the-keyboard-plug-in-for-lvgl-moves-in-any-position-on-the-screen/3824/6 "2024-09-24T06:18:46Z")

</div>

But it’s just a convenience macro, you can still limit your coordinates to the screen-resolution by a custom simple code or function.

---

<div class="post-metadata">

**Author:** ![sunboy](http://forum.squareline.io/letter_avatar_proxy/v4/letter/s/e19b73/32.png) [@sunboy](http://forum.squareline.io/u/sunboy)\
**Post date:** [September 25, 2024, 1:49am UTC](http://forum.squareline.io/t/the-keyboard-plug-in-for-lvgl-moves-in-any-position-on-the-screen/3824/7 "2024-09-25T01:49:06Z")

</div>

Well, thanks for your guidance!
