mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 19:58:54 +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))
|
g.textFields = append(g.textFields, NewTextField(image.Rect(16, 80, screenWidth-16, screenHeight-16), true))
|
||||||
}
|
}
|
||||||
|
|
||||||
if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonLeft) {
|
ids := inpututil.AppendJustPressedTouchIDs(nil)
|
||||||
x, y := ebiten.CursorPosition()
|
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 {
|
for _, tf := range g.textFields {
|
||||||
if tf.Contains(x, y) {
|
if tf.Contains(x, y) {
|
||||||
tf.Focus()
|
tf.Focus()
|
||||||
|
Loading…
Reference in New Issue
Block a user