Skip to content

Commit

Permalink
When we leave the window invalidate our tracked cursor position
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Mar 26, 2021
1 parent 42d1237 commit 78c1d13
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/driver/glfw/window.go
Expand Up @@ -702,6 +702,11 @@ func (w *window) mouseOut() {
}

func (w *window) mouseClicked(_ *glfw.Window, btn glfw.MouseButton, action glfw.Action, mods glfw.ModifierKey) {
if w.mousePos.IsZero() { // window may not be focused (darwin mostly) and so position callbacks not happening
xpos, ypos := w.viewport.GetCursorPos()
w.mousePos = fyne.NewPos(internal.UnscaleInt(w.canvas, int(xpos)), internal.UnscaleInt(w.canvas, int(ypos)))
}

co, pos, _ := w.findObjectAtPositionMatching(w.canvas, w.mousePos, func(object fyne.CanvasObject) bool {
switch object.(type) {
case fyne.Tappable, fyne.SecondaryTappable, fyne.DoubleTappable, fyne.Focusable, desktop.Mouseable, desktop.Hoverable:
Expand Down Expand Up @@ -1184,6 +1189,7 @@ func (w *window) focused(_ *glfw.Window, isFocused bool) {
w.canvas.FocusGained()
} else {
w.canvas.FocusLost()
w.mousePos = fyne.Position{}
}
}

Expand Down

0 comments on commit 78c1d13

Please sign in to comment.