objects/textview.go

28 lines
713 B
Go

package objects
import "image"
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/theme"
// TextView is an area for displaying a large amount of multi-line text.
type TextView struct {
tomo.TextBox
}
// NewTextView creates a new text view.
func NewTextView (text string) *TextView {
this := &TextView { TextBox: tomo.NewTextBox() }
theme.Apply(this, theme.R("objects", "TextView", ""))
this.SetFocusable(true)
this.SetSelectable(true)
this.SetText(text)
this.SetOverflow(false, true)
this.SetWrap(true)
this.OnScroll(this.handleScroll)
return this
}
func (this *TextView) handleScroll (x, y float64) {
this.ScrollTo(this.ContentBounds().Min.Add(image.Pt(int(x), int(y))))
}