Added applyCursorVisibility()
This commit is contained in:
parent
3f65b2c0c8
commit
bca31f0d7a
|
@ -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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue