28 lines
701 B
Go
28 lines
701 B
Go
package objects
|
|
|
|
import "image"
|
|
import "git.tebibyte.media/tomo/tomo"
|
|
|
|
// 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() }
|
|
this.SetRole(tomo.R("objects", "TextView"))
|
|
this.SetFocusable(true)
|
|
this.SetSelectable(true)
|
|
this.SetText(text)
|
|
this.SetAttr(tomo.AOverflow(false, true))
|
|
this.SetAttr(tomo.AWrap(true))
|
|
this.OnScroll(this.handleScroll)
|
|
return this
|
|
}
|
|
|
|
func (this *TextView) handleScroll (x, y float64) bool {
|
|
this.ScrollTo(this.ContentBounds().Min.Sub(image.Pt(int(x), int(y))))
|
|
return true
|
|
}
|