Added applyCursorVisibility()

This commit is contained in:
theGeekPirate 2017-10-27 14:13:22 -07:00 committed by GitHub
parent 3f65b2c0c8
commit bca31f0d7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 10 deletions

View File

@ -324,15 +324,19 @@ func (w *Window) SetCursorVisible(visible bool) {
if !w.cursorDisabled { if !w.cursorDisabled {
w.cursorVisible = visible w.cursorVisible = visible
mainthread.Call(func() { mainthread.Call(func() {
if visible { w.applyCursorVisibility()
w.window.SetInputMode(glfw.CursorMode, glfw.CursorNormal)
} else {
w.window.SetInputMode(glfw.CursorMode, glfw.CursorHidden)
}
}) })
} }
} }
func (w *Window) applyCursorVisibility() {
if w.cursorVisible {
w.window.SetInputMode(glfw.CursorMode, glfw.CursorNormal)
} else {
w.window.SetInputMode(glfw.CursorMode, glfw.CursorHidden)
}
}
// CursorVisible returns the visibility status of the mouse cursor. // CursorVisible returns the visibility status of the mouse cursor.
func (w *Window) CursorVisible() bool { func (w *Window) CursorVisible() bool {
return w.cursorVisible return w.cursorVisible
@ -346,11 +350,7 @@ func (w *Window) SetCursorDisabled(disabled bool) {
w.cursorVisible = false w.cursorVisible = false
w.window.SetInputMode(glfw.CursorMode, glfw.CursorDisabled) w.window.SetInputMode(glfw.CursorMode, glfw.CursorDisabled)
} else { } else {
if w.cursorVisible { w.applyCursorVisibility()
w.window.SetInputMode(glfw.CursorMode, glfw.CursorNormal)
} else {
w.window.SetInputMode(glfw.CursorMode, glfw.CursorHidden)
}
} }
}) })
} }