Fix input focus ordering

This commit is contained in:
Trevor Slocum 2023-10-27 22:29:30 -07:00
parent 69118f50b2
commit 07b308bcc0
4 changed files with 6 additions and 6 deletions

2
box.go
View file

@ -67,7 +67,7 @@ func (b *Box) Focus() bool {
}
func (b *Box) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error) {
return true, nil
return false, nil
}
func (b *Box) HandleKeyboard(key ebiten.Key, r rune) (handled bool, err error) {

View file

@ -183,8 +183,8 @@ func update(w Widget, cursor image.Point, pressed bool, clicked bool, mouseHandl
var err error
children := w.Children()
for _, child := range children {
mouseHandled, err = update(child, cursor, pressed, clicked, mouseHandled)
for i := len(children) - 1; i >= 0; i-- {
mouseHandled, err = update(children[i], cursor, pressed, clicked, mouseHandled)
if err != nil {
return false, err
} else if mouseHandled {

2
go.mod
View file

@ -3,7 +3,7 @@ module code.rocket9labs.com/tslocum/etk
go 1.18
require (
code.rocketnine.space/tslocum/messeji v1.0.5-0.20231028050054-75c3e5625ec6
code.rocketnine.space/tslocum/messeji v1.0.5-0.20231028055625-e3d27e092278
github.com/hajimehoshi/ebiten/v2 v2.6.2
golang.org/x/image v0.13.0
)

4
go.sum
View file

@ -1,5 +1,5 @@
code.rocketnine.space/tslocum/messeji v1.0.5-0.20231028050054-75c3e5625ec6 h1:HdPb+xfqoRxKJcB9dPshwBALGTSCCMxlzLMgmHAXv2U=
code.rocketnine.space/tslocum/messeji v1.0.5-0.20231028050054-75c3e5625ec6/go.mod h1:xszLyTZtpyjCVaGmznizLSAlnvraPOSoanlzUBeqGco=
code.rocketnine.space/tslocum/messeji v1.0.5-0.20231028055625-e3d27e092278 h1:ef5eeSgFSQnLA17pGv/VEBW1mC3qLTjOZ/yTTc1rhzo=
code.rocketnine.space/tslocum/messeji v1.0.5-0.20231028055625-e3d27e092278/go.mod h1:xszLyTZtpyjCVaGmznizLSAlnvraPOSoanlzUBeqGco=
github.com/ebitengine/purego v0.5.0 h1:JrMGKfRIAM4/QVKaesIIT7m/UVjTj5GYhRSQYwfVdpo=
github.com/ebitengine/purego v0.5.0/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ=
github.com/hajimehoshi/bitmapfont/v3 v3.0.0 h1:r2+6gYK38nfztS/et50gHAswb9hXgxXECYgE8Nczmi4=