mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
examples/textinput: bug fix: accept touches
The remaining task is to enable a backspace key. Updates #2898
This commit is contained in:
parent
872ffc148d
commit
f9fa5a14f2
@ -310,8 +310,14 @@ func (g *Game) Update() error {
|
||||
g.textFields = append(g.textFields, NewTextField(image.Rect(16, 80, screenWidth-16, screenHeight-16), true))
|
||||
}
|
||||
|
||||
if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonLeft) {
|
||||
x, y := ebiten.CursorPosition()
|
||||
ids := inpututil.AppendJustPressedTouchIDs(nil)
|
||||
if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonLeft) || len(ids) > 0 {
|
||||
var x, y int
|
||||
if len(ids) > 0 {
|
||||
x, y = ebiten.TouchPosition(ids[0])
|
||||
} else {
|
||||
x, y = ebiten.CursorPosition()
|
||||
}
|
||||
for _, tf := range g.textFields {
|
||||
if tf.Contains(x, y) {
|
||||
tf.Focus()
|
||||
|
Loading…
Reference in New Issue
Block a user