Me, trying to figure out how to implement basic drag functionality in #Bevy#BevyEngine UI without the cursor jumping to the mid-point of the dragged rectangle.😬
@mo8it Basically yes. I try to calculate CSS relative position from the top-left parent rect for the red inner rect (think of CSS' top and left properties) when you drag the red inner rect.
And with my different calculations I've tried, I always manage it that all values cancel each other out, so when you try to drag the red inner most rectangle...nothing happens (but the code gets executed).😳
@janriemer Well, then from what you drew, the length of c is for sure not length of a - length of b. Or are these vectors? In that case, yes, |a - b| = |c|
@janriemer@mo8it If you capture the mouse position and center point when the drag is initiated, and calculate the starting position of the upper left corner by subtracting width/2 from x and adding height/2 to y, then after that, the (∆x, ∆y) of the mouse position (relative to its starting position) is also the (∆x, ∆y) for every other point on the rectangle (relative to their respective starting positions).
but it has a bug in it and I'm trying to fix it. Currently, it doesn't store the starting mouse position and center point at drag-initiation at all, so I thought this shouldn't be necessary
Add comment