From 4c6d98879ebddf4d4a0e76ff3dfdc0eb593856fd Mon Sep 17 00:00:00 2001 From: Pierre Curto Date: Thu, 6 Jan 2022 19:16:17 +0100 Subject: [PATCH] widget: add Draggable.Pos When the position of the cursor is required while dragging a widget around, the pointer's cannot be tracked as the drag grabs the event priority. Therefore, this patch exposes the drag's current position. Signed-off-by: Pierre Curto --- widget/dnd.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/widget/dnd.go b/widget/dnd.go index 70d9283f..bed52bc2 100644 --- a/widget/dnd.go +++ b/widget/dnd.go @@ -96,3 +96,8 @@ func (d *Draggable) Offer(ops *op.Ops, mime string, data io.ReadCloser) { Data: data, }.Add(ops) } + +// Pos returns the drag position relative to its area. +func (d *Draggable) Pos() f32.Point { + return d.pos.Add(d.click) +}