internal/uidriver/js: Bug fix: CursorPosition crashed before the main loop on browsers

Closes #1559
This commit is contained in:
Hajime Hoshi 2021-04-07 03:05:57 +09:00
parent 0300be7d9e
commit ad3c76b6d9

View File

@ -83,6 +83,9 @@ type Input struct {
} }
func (i *Input) CursorPosition() (x, y int) { 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()) xf, yf := i.ui.context.AdjustPosition(float64(i.cursorX), float64(i.cursorY), i.ui.DeviceScaleFactor())
return int(xf), int(yf) return int(xf), int(yf)
} }