'Kivy drag n drop area is too big

Reposting this with example code from geeksforgeeks. I am testing a simple drag and drop function in Kivy with the Drag Behavior module:

https://kivy.org/doc/stable/api-kivy.uix.behaviors.drag.html

However, I can't seem to work out how to make the draggable area small. I've tried playing around with the numbers on the drag_rectangle parameters, but the draggable area either doesn't get smaller or just completely disappears for some reason (meaning I can't drag the square). For reference, this is the issue:

enter image description here

If you run the code in this geeksforgeeks sample the same problem happens so I think it has to something to do with the module itself: https://www.geeksforgeeks.org/how-to-add-drag-behavior-in-kivy-widget/



Solution 1:[1]

Referring the link you provided.

The drag behavior is applied to the widget (here, Label) which is triggered when the touch is within drag_rectangle (default position is (0, 0)). Here this is set to be the whole widget (drag_rectangle: self.x, self.y, self.width, self.height).

However, I can't seem to work out how to make the draggable area small...

I think that can be achieved either by restricting the drag rectangle by something like,

drag_rectangle: self.center_x - dp(100), self.center_y - dp(100), dp(200), dp(200) # Within a square of length dp(100) centered at widget's center.

Or by limiting the appearance (physical boundary) of the widget using size/size_hint,

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1