Make Text.Field and Input.Field public
This commit is contained in:
parent
f12353f314
commit
585e23b06f
2 changed files with 15 additions and 15 deletions
16
input.go
16
input.go
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
type Input struct {
|
||||
*Box
|
||||
field *messeji.InputField
|
||||
Field *messeji.InputField
|
||||
}
|
||||
|
||||
func NewInput(prefix string, text string, onSelected func(text string) (handled bool)) *Input {
|
||||
|
@ -31,28 +31,28 @@ func NewInput(prefix string, text string, onSelected func(text string) (handled
|
|||
|
||||
return &Input{
|
||||
Box: NewBox(),
|
||||
field: i,
|
||||
Field: i,
|
||||
}
|
||||
}
|
||||
|
||||
// Clear clears the field's buffer.
|
||||
func (i *Input) Clear() {
|
||||
i.field.SetText("")
|
||||
i.Field.SetText("")
|
||||
}
|
||||
|
||||
// Write writes to the field's buffer.
|
||||
func (i *Input) Write(p []byte) (n int, err error) {
|
||||
return i.field.Write(p)
|
||||
return i.Field.Write(p)
|
||||
}
|
||||
|
||||
func (i *Input) Text() string {
|
||||
return i.field.Text()
|
||||
return i.Field.Text()
|
||||
}
|
||||
|
||||
func (i *Input) SetRect(r image.Rectangle) {
|
||||
i.Box.rect = r
|
||||
|
||||
i.field.SetRect(r)
|
||||
i.Field.SetRect(r)
|
||||
}
|
||||
|
||||
func (i *Input) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error) {
|
||||
|
@ -60,13 +60,13 @@ func (i *Input) HandleMouse(cursor image.Point, pressed bool, clicked bool) (han
|
|||
}
|
||||
|
||||
func (i *Input) HandleKeyboard() (handled bool, err error) {
|
||||
err = i.field.Update()
|
||||
err = i.Field.Update()
|
||||
|
||||
return false, err
|
||||
}
|
||||
|
||||
func (i *Input) Draw(screen *ebiten.Image) error {
|
||||
// Draw label.
|
||||
i.field.Draw(screen)
|
||||
i.Field.Draw(screen)
|
||||
return nil
|
||||
}
|
||||
|
|
14
text.go
14
text.go
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
type Text struct {
|
||||
*Box
|
||||
field *messeji.TextField
|
||||
Field *messeji.TextField
|
||||
}
|
||||
|
||||
func NewText(text string) *Text {
|
||||
|
@ -25,28 +25,28 @@ func NewText(text string) *Text {
|
|||
|
||||
return &Text{
|
||||
Box: NewBox(),
|
||||
field: l,
|
||||
Field: l,
|
||||
}
|
||||
}
|
||||
|
||||
// Clear clears the field's buffer.
|
||||
func (t *Text) Clear() {
|
||||
t.field.SetText("")
|
||||
t.Field.SetText("")
|
||||
}
|
||||
|
||||
// Write writes to the field's buffer.
|
||||
func (t *Text) Write(p []byte) (n int, err error) {
|
||||
return t.field.Write(p)
|
||||
return t.Field.Write(p)
|
||||
}
|
||||
|
||||
func (t *Text) Text() string {
|
||||
return t.field.Text()
|
||||
return t.Field.Text()
|
||||
}
|
||||
|
||||
func (t *Text) SetRect(r image.Rectangle) {
|
||||
t.Box.rect = r
|
||||
|
||||
t.field.SetRect(r)
|
||||
t.Field.SetRect(r)
|
||||
}
|
||||
|
||||
func (t *Text) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error) {
|
||||
|
@ -59,6 +59,6 @@ func (t *Text) HandleKeyboard() (handled bool, err error) {
|
|||
|
||||
func (t *Text) Draw(screen *ebiten.Image) error {
|
||||
// Draw label.
|
||||
t.field.Draw(screen)
|
||||
t.Field.Draw(screen)
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue