uidriver: Copy the runes on the callee sides

This commit is contained in:
Hajime Hoshi 2020-11-18 19:37:12 +09:00
parent 82dc7a6591
commit 14070ee153
4 changed files with 9 additions and 5 deletions

View File

@ -32,8 +32,7 @@ import (
//
// Keyboards don't work on iOS yet (#1090).
func InputChars() []rune {
rb := uiDriver().Input().RuneBuffer()
return append(make([]rune, 0, len(rb)), rb...)
return uiDriver().Input().RuneBuffer()
}
// IsKeyPressed returns a boolean indicating whether key is pressed.

View File

@ -218,7 +218,8 @@ func (i *Input) RuneBuffer() []rune {
}
var r []rune
_ = i.ui.t.Call(func() error {
r = i.runeBuffer
r = make([]rune, len(i.runeBuffer))
copy(r, i.runeBuffer)
return nil
})
return r

View File

@ -142,7 +142,9 @@ func (i *Input) TouchPosition(id driver.TouchID) (x, y int) {
}
func (i *Input) RuneBuffer() []rune {
return i.runeBuffer
rs := make([]rune, len(i.runeBuffer))
copy(rs, i.runeBuffer)
return rs
}
func (i *Input) resetForFrame() {

View File

@ -164,7 +164,9 @@ func (i *Input) TouchPosition(id driver.TouchID) (x, y int) {
}
func (i *Input) RuneBuffer() []rune {
return i.runes
rs := make([]rune, len(i.runes))
copy(rs, i.runes)
return rs
}
func (i *Input) IsKeyPressed(key driver.Key) bool {