Label no longer embeds tomo.TextBox
This commit is contained in:
parent
0960fe013d
commit
c7caa5bcb6
51
label.go
51
label.go
@ -1,19 +1,58 @@
|
||||
package objects
|
||||
|
||||
import "git.tebibyte.media/tomo/tomo"
|
||||
import "git.tebibyte.media/tomo/tomo/text"
|
||||
import "git.tebibyte.media/tomo/tomo/event"
|
||||
|
||||
// Label is a simple text label.
|
||||
type Label struct {
|
||||
tomo.TextBox
|
||||
box tomo.TextBox
|
||||
}
|
||||
|
||||
// NewLabel creates a new text label.
|
||||
func NewLabel (text string) *Label {
|
||||
this := &Label { TextBox: tomo.NewTextBox() }
|
||||
this.SetRole(tomo.R("objects", "Label"))
|
||||
this := &Label { box: tomo.NewTextBox() }
|
||||
this.box.SetRole(tomo.R("objects", "Label"))
|
||||
this.SetText(text)
|
||||
this.SetAttr(tomo.AAlign(tomo.AlignStart, tomo.AlignMiddle))
|
||||
this.SetSelectable(true)
|
||||
this.SetFocusable(true)
|
||||
this.box.SetAttr(tomo.AAlign(tomo.AlignStart, tomo.AlignMiddle))
|
||||
this.box.SetSelectable(true)
|
||||
this.box.SetFocusable(true)
|
||||
return this
|
||||
}
|
||||
|
||||
// GetBox returns the underlying box.
|
||||
func (this *Label) GetBox () tomo.Box {
|
||||
return this.box
|
||||
}
|
||||
|
||||
// SetFocused sets whether or not this label has keyboard focus. If set to true,
|
||||
// this method will steal focus away from whichever object currently has focus.
|
||||
func (this *Label) SetFocused (focused bool) {
|
||||
this.box.SetFocused(focused)
|
||||
}
|
||||
|
||||
// SetText sets the text content of the heading.
|
||||
func (this *Label) SetText (text string) {
|
||||
this.box.SetText(text)
|
||||
}
|
||||
|
||||
// Select sets the text cursor or selection.
|
||||
func (this *Label) Select (dot text.Dot) {
|
||||
this.box.Select(dot)
|
||||
}
|
||||
|
||||
// Dot returns the text cursor or selection.
|
||||
func (this *Label) Dot () text.Dot {
|
||||
return this.box.Dot()
|
||||
}
|
||||
|
||||
// SetAlign sets the X and Y alignment of the label.
|
||||
func (this *Label) SetAlign (x, y tomo.Align) {
|
||||
this.box.SetAttr(tomo.AAlign(x, y))
|
||||
}
|
||||
|
||||
// OnDotChange specifies a function to be called when the text cursor or
|
||||
// selection changes.
|
||||
func (this *Label) OnDotChange (callback func ()) event.Cookie {
|
||||
return this.box.OnDotChange(callback)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user