Pass mouse input to Text and Input widgets

This commit is contained in:
Trevor Slocum 2023-10-27 16:26:03 -07:00
parent 96b3a2a50f
commit 80d56f9c28
4 changed files with 7 additions and 7 deletions

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.4
code.rocketnine.space/tslocum/messeji v1.0.5-0.20231027235104-784342f8110a
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.4 h1:8hDIu1iFXDPc/l84rU0lQIxTT13uSRSQbTWYIdTqlXQ=
code.rocketnine.space/tslocum/messeji v1.0.4/go.mod h1:xszLyTZtpyjCVaGmznizLSAlnvraPOSoanlzUBeqGco=
code.rocketnine.space/tslocum/messeji v1.0.5-0.20231027235104-784342f8110a h1:s3mTWILsEJxS69ETQWDj+aaajCLt/KDZ0iqJPGRW7kY=
code.rocketnine.space/tslocum/messeji v1.0.5-0.20231027235104-784342f8110a/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=

View file

@ -74,7 +74,7 @@ func (i *Input) Focused() bool {
}
func (i *Input) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error) {
return true, nil
return true, i.Field.Update()
}
func (i *Input) HandleKeyboard() (handled bool, err error) {

View file

@ -79,15 +79,15 @@ func (t *Text) Text() string {
}
func (t *Text) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error) {
return false, nil
return t.TextField.HandleMouseEvent(cursor, pressed, clicked)
}
func (t *Text) HandleKeyboard() (handled bool, err error) {
return false, nil
}
func (f *Text) HandleKeyboardEvent(key ebiten.Key, r rune) (handled bool, err error) {
return false, nil
func (t *Text) HandleKeyboardEvent(key ebiten.Key, r rune) (handled bool, err error) {
return t.TextField.HandleKeyboardEvent(key, r)
}
func (t *Text) Draw(screen *ebiten.Image) error {