mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2026-04-23 00:07:15 +08:00
exp/textinput, examples/textinput: bug fix: handle input states correctly on Android Chrome
Updates #2898
This commit is contained in:
@@ -138,6 +138,21 @@ func (t *TextField) Blur() {
|
||||
|
||||
func (t *TextField) Update() {
|
||||
if !t.focused {
|
||||
// If the text field still has a session, read the last state and process it just in case.
|
||||
if t.ch != nil {
|
||||
select {
|
||||
case state, ok := <-t.ch:
|
||||
if ok && state.Committed {
|
||||
t.text = t.text[:t.selectionStart] + state.Text + t.text[t.selectionEnd:]
|
||||
t.selectionStart += len(state.Text)
|
||||
t.selectionEnd = t.selectionStart
|
||||
t.state = textinput.State{}
|
||||
}
|
||||
t.state = state
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
if t.end != nil {
|
||||
t.end()
|
||||
t.ch = nil
|
||||
|
||||
Reference in New Issue
Block a user