Update code for layouts, objects

This commit is contained in:
2024-07-21 11:48:28 -04:00
parent 9077015db6
commit 6ca6771fc6
26 changed files with 447 additions and 389 deletions

View File

@@ -20,14 +20,14 @@ func NewLabelCheckbox (value bool, text string) *LabelCheckbox {
checkbox: NewCheckbox(value),
label: NewLabel(text),
}
box.SetRole(tomo.R("objects", "LabelCheckbox", ""))
box.label.SetAlign(tomo.AlignStart, tomo.AlignMiddle)
box.SetRole(tomo.R("objects", "LabelCheckbox"))
box.label.SetAttr(tomo.AAlign(tomo.AlignStart, tomo.AlignMiddle))
box.Add(box.checkbox)
box.Add(box.label)
box.SetLayout(layouts.Row { false, true })
box.OnMouseUp(box.handleMouseUp)
box.label.OnMouseUp(box.handleMouseUp)
box.OnButtonDown(box.handleButtonDown)
box.OnButtonUp(box.handleButtonUp)
return box
}
@@ -52,9 +52,14 @@ func (this *LabelCheckbox) OnValueChange (callback func ()) event.Cookie {
return this.checkbox.OnValueChange(callback)
}
func (this *LabelCheckbox) handleMouseUp (button input.Button) {
func (this *LabelCheckbox) handleButtonDown (capture func (), button input.Button) {
capture()
}
func (this *LabelCheckbox) handleButtonUp (capture func (), button input.Button) {
capture()
if button != input.ButtonLeft { return }
if this.MousePosition().In(this.Bounds()) {
if this.Window().MousePosition().In(this.Bounds()) {
this.checkbox.SetFocused(true)
this.checkbox.Toggle()
}