mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
ui: Add SetCursorVisibility (#258)
This commit is contained in:
parent
417112c586
commit
cd885ce7c5
@ -142,6 +142,20 @@ func ScreenScale() float64 {
|
||||
return s
|
||||
}
|
||||
|
||||
func SetCursorVisibility(visible bool) {
|
||||
// This can be called before Run: change the state asyncly.
|
||||
go func() {
|
||||
_ = currentUI.runOnMainThread(func() error {
|
||||
c := glfw.CursorNormal
|
||||
if !visible {
|
||||
c = glfw.CursorHidden
|
||||
}
|
||||
currentUI.window.SetInputMode(glfw.CursorMode, c)
|
||||
return nil
|
||||
})
|
||||
}()
|
||||
}
|
||||
|
||||
func Run(width, height int, scale float64, title string, g GraphicsContext) error {
|
||||
u := currentUI
|
||||
// GLContext must be created before setting the screen size, which requires
|
||||
|
@ -57,6 +57,14 @@ func ScreenScale() float64 {
|
||||
return currentUI.scale
|
||||
}
|
||||
|
||||
func SetCursorVisibility(visibility bool) {
|
||||
if visibility {
|
||||
canvas.Get("style").Set("cursor", "auto")
|
||||
} else {
|
||||
canvas.Get("style").Set("cursor", "none")
|
||||
}
|
||||
}
|
||||
|
||||
func (u *userInterface) actualScreenScale() float64 {
|
||||
return u.scale * u.deviceScale
|
||||
}
|
||||
|
@ -112,6 +112,10 @@ func ScreenScale() float64 {
|
||||
return currentUI.scale
|
||||
}
|
||||
|
||||
func SetCursorVisibility(visibility bool) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
func (u *userInterface) actualScreenScale() float64 {
|
||||
return u.scale * deviceScale()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user