Replaced SetCursorMode() with SetCursorDisabled()
This commit is contained in:
parent
bec153a1b5
commit
ec0dbe4fc4
|
@ -318,41 +318,14 @@ func (w *Window) VSync() bool {
|
||||||
return w.vsync
|
return w.vsync
|
||||||
}
|
}
|
||||||
|
|
||||||
// cursorMode uses magic numbers from https://github.com/glfw/glfw/blob/32e78aeb2edb5cb5add36ae575fc914f6c4fc7e5/include/GLFW/glfw3.h#L966
|
// SetCursorDisabled both hides the cursor, as well as limits cursor movement to the Window client area.
|
||||||
type cursorMode int
|
func (w *Window) SetCursorDisabled(disabled bool) {
|
||||||
|
w.cursorVisible = false
|
||||||
const (
|
|
||||||
// CursorNormal displays the regular cursor (or another set with glfw.SetCursor()), and
|
|
||||||
// does not limit cursor motion.
|
|
||||||
CursorNormal cursorMode = 0x00034001
|
|
||||||
// CursorHidden hides the cursor, and does not limit cursor motion.
|
|
||||||
CursorHidden cursorMode = 0x00034002
|
|
||||||
// CursorDisabled both hides the cursor, as well as limits cursor movement to the window.
|
|
||||||
CursorDisabled cursorMode = 0x00034003
|
|
||||||
)
|
|
||||||
|
|
||||||
// SetCursorMode determines how the mouse cursor appears and behaves.
|
|
||||||
func (w *Window) SetCursorMode(cm cursorMode) {
|
|
||||||
mainthread.Call(func() {
|
mainthread.Call(func() {
|
||||||
switch cm {
|
if disabled {
|
||||||
case CursorNormal:
|
|
||||||
w.window.SetInputMode(glfw.CursorMode, glfw.CursorNormal)
|
|
||||||
case CursorHidden:
|
|
||||||
w.window.SetInputMode(glfw.CursorMode, glfw.CursorHidden)
|
|
||||||
case CursorDisabled:
|
|
||||||
w.window.SetInputMode(glfw.CursorMode, glfw.CursorDisabled)
|
w.window.SetInputMode(glfw.CursorMode, glfw.CursorDisabled)
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetCursorVisible sets the visibility of the mouse cursor inside the Window client area.
|
|
||||||
func (w *Window) SetCursorVisible(visible bool) {
|
|
||||||
w.cursorVisible = visible
|
|
||||||
mainthread.Call(func() {
|
|
||||||
if visible {
|
|
||||||
w.window.SetInputMode(glfw.CursorMode, glfw.CursorNormal)
|
|
||||||
} else {
|
} else {
|
||||||
w.window.SetInputMode(glfw.CursorMode, glfw.CursorHidden)
|
w.window.SetInputMode(glfw.CursorMode, glfw.CursorNormal)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue