Add Focus to Widget interface
This commit is contained in:
parent
4833fa2b27
commit
6e8eb92a2c
4 changed files with 14 additions and 12 deletions
11
box.go
11
box.go
|
@ -51,19 +51,20 @@ func (b *Box) SetBackground(background color.RGBA) {
|
|||
b.background = background
|
||||
}
|
||||
|
||||
func (b *Box) Focus() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (b *Box) SetFocus(focus bool) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (b *Box) SetVisible(visible bool) {
|
||||
b.visible = visible
|
||||
}
|
||||
func (b *Box) Visible() bool {
|
||||
return b.visible
|
||||
}
|
||||
|
||||
func (b *Box) Focus() bool {
|
||||
return false
|
||||
func (b *Box) SetVisible(visible bool) {
|
||||
b.visible = visible
|
||||
}
|
||||
|
||||
func (b *Box) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error) {
|
||||
|
|
8
input.go
8
input.go
|
@ -58,6 +58,10 @@ func (i *Input) SetRect(r image.Rectangle) {
|
|||
i.Field.SetRect(r)
|
||||
}
|
||||
|
||||
func (i *Input) Focus() bool {
|
||||
return i.focus
|
||||
}
|
||||
|
||||
func (i *Input) SetFocus(focus bool) bool {
|
||||
i.focus = focus
|
||||
|
||||
|
@ -69,10 +73,6 @@ func (i *Input) SetFocus(focus bool) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func (i *Input) Focused() bool {
|
||||
return i.focus
|
||||
}
|
||||
|
||||
func (i *Input) HandleKeyboard(key ebiten.Key, r rune) (handled bool, err error) {
|
||||
if !i.focus {
|
||||
return false, nil
|
||||
|
|
4
text.go
4
text.go
|
@ -44,11 +44,11 @@ func (t *Text) SetBackground(background color.RGBA) {
|
|||
t.background = background
|
||||
}
|
||||
|
||||
func (t *Text) SetFocus(focus bool) bool {
|
||||
func (t *Text) Focus() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (t *Text) Focus() bool {
|
||||
func (t *Text) SetFocus(focus bool) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,10 @@ type Widget interface {
|
|||
SetRect(r image.Rectangle)
|
||||
Background() color.RGBA
|
||||
SetBackground(background color.RGBA)
|
||||
Focus() bool
|
||||
SetFocus(focus bool) (accept bool)
|
||||
SetVisible(visible bool)
|
||||
Visible() bool
|
||||
SetVisible(visible bool)
|
||||
HandleKeyboard(ebiten.Key, rune) (handled bool, err error)
|
||||
HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
|
||||
Draw(screen *ebiten.Image) error
|
||||
|
|
Loading…
Reference in a new issue