mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
ui: Adjust cursor positoin on fullscreen mode (#374)
This commit is contained in:
parent
c694851765
commit
ba204c6d3b
@ -28,7 +28,7 @@ func CurrentInput() *Input {
|
||||
func (i *Input) CursorPosition() (x, y int) {
|
||||
i.m.RLock()
|
||||
defer i.m.RUnlock()
|
||||
return i.cursorX, i.cursorY
|
||||
return adjustCursorPosition(i.cursorX, i.cursorY)
|
||||
}
|
||||
|
||||
func (i *Input) GamepadAxisNum(id int) int {
|
||||
|
@ -214,6 +214,20 @@ func ScreenOffset() (float64, float64) {
|
||||
return ox, oy
|
||||
}
|
||||
|
||||
func adjustCursorPosition(x, y int) (int, int) {
|
||||
u := currentUI
|
||||
if !u.isRunning() {
|
||||
return x, y
|
||||
}
|
||||
ox, oy := ScreenOffset()
|
||||
s := 0.0
|
||||
_ = currentUI.runOnMainThread(func() error {
|
||||
s = currentUI.actualScreenScale()
|
||||
return nil
|
||||
})
|
||||
return x - int(ox/s), y - int(oy/s)
|
||||
}
|
||||
|
||||
func SetCursorVisibility(visible bool) {
|
||||
// This can be called before Run: change the state asyncly.
|
||||
go func() {
|
||||
|
@ -70,6 +70,10 @@ func ScreenOffset() (float64, float64) {
|
||||
return 0, 0
|
||||
}
|
||||
|
||||
func adjustCursorPosition(x, y int) (int, int) {
|
||||
return x, y
|
||||
}
|
||||
|
||||
func SetCursorVisibility(visibility bool) {
|
||||
if visibility {
|
||||
canvas.Get("style").Set("cursor", "auto")
|
||||
|
@ -110,6 +110,10 @@ func ScreenOffset() (float64, float64) {
|
||||
return 0, 0
|
||||
}
|
||||
|
||||
func adjustCursorPosition(x, y int) (int, int) {
|
||||
return x, y
|
||||
}
|
||||
|
||||
func SetCursorVisibility(visibility bool) {
|
||||
// Do nothing
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user