Fix InputField.Update
This commit is contained in:
parent
953d4984d2
commit
a7368da290
1 changed files with 5 additions and 2 deletions
|
@ -1,6 +1,8 @@
|
|||
package messeji
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2"
|
||||
"github.com/hajimehoshi/ebiten/v2/inpututil"
|
||||
"golang.org/x/image/font"
|
||||
|
@ -24,6 +26,8 @@ type InputField struct {
|
|||
|
||||
// readBuffer is where incoming runes are stored before being added to the input buffer.
|
||||
readBuffer []rune
|
||||
|
||||
sync.Mutex
|
||||
}
|
||||
|
||||
// NewInputField returns a new InputField. See type documentation for more info.
|
||||
|
@ -68,13 +72,13 @@ func (f *InputField) SetSelectedFunc(selectedFunc func() (accept bool)) {
|
|||
// Game.Update is called.
|
||||
func (f *InputField) Update() error {
|
||||
f.Lock()
|
||||
defer f.Unlock()
|
||||
|
||||
if !f.visible || rectIsZero(f.r) {
|
||||
return nil
|
||||
}
|
||||
|
||||
if !f.handleKeyboard {
|
||||
f.Unlock()
|
||||
return f.TextField.Update()
|
||||
}
|
||||
|
||||
|
@ -123,6 +127,5 @@ func (f *InputField) Update() error {
|
|||
f.bufferModified()
|
||||
}
|
||||
|
||||
f.Unlock()
|
||||
return f.TextField.Update()
|
||||
}
|
||||
|
|
Reference in a new issue