From e8d9fcf220debcfcf970b6a3829ad319d331cf3f Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 18 Apr 2021 04:57:55 +0900 Subject: [PATCH] internal/uidriver/js: Bug fix: CursorPosition crashed before the main loop on browsers Closes #1559 --- internal/uidriver/js/input.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/uidriver/js/input.go b/internal/uidriver/js/input.go index af91a29b6..e4e25d696 100644 --- a/internal/uidriver/js/input.go +++ b/internal/uidriver/js/input.go @@ -54,6 +54,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)) return int(xf), int(yf) }