From ad3c76b6d9891c77d06ac8b849119b40ef97a64d Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 7 Apr 2021 03:05:57 +0900 Subject: [PATCH] internal/uidriver/js: Bug fix: CursorPosition crashed before the main loop on browsers Closes #1559 --- internal/uidriver/js/input_js.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/uidriver/js/input_js.go b/internal/uidriver/js/input_js.go index 1727a6ab0..c438ee0cb 100644 --- a/internal/uidriver/js/input_js.go +++ b/internal/uidriver/js/input_js.go @@ -83,6 +83,9 @@ type Input struct { } func (i *Input) CursorPosition() (x, y int) { + if i.ui.context == nil { + return 0, 0 + } xf, yf := i.ui.context.AdjustPosition(float64(i.cursorX), float64(i.cursorY), i.ui.DeviceScaleFactor()) return int(xf), int(yf) }