Update code for layouts, objects
This commit is contained in:
12
swatch.go
12
swatch.go
@@ -26,11 +26,11 @@ func NewSwatch (value color.Color) *Swatch {
|
||||
swatch := &Swatch {
|
||||
CanvasBox: tomo.NewCanvasBox(),
|
||||
}
|
||||
swatch.SetRole(tomo.R("objects", "Swatch", ""))
|
||||
swatch.SetRole(tomo.R("objects", "Swatch"))
|
||||
swatch.SetDrawer(swatch)
|
||||
swatch.SetValue(value)
|
||||
|
||||
swatch.OnMouseUp(swatch.handleMouseUp)
|
||||
swatch.OnButtonUp(swatch.handleButtonUp)
|
||||
swatch.OnKeyUp(swatch.handleKeyUp)
|
||||
swatch.SetFocusable(true)
|
||||
return swatch
|
||||
@@ -114,7 +114,7 @@ func (this *Swatch) Choose () {
|
||||
layouts.ContractHorizontal,
|
||||
cancelButton,
|
||||
okButton)
|
||||
controlRow.SetAlign(tomo.AlignEnd, tomo.AlignMiddle)
|
||||
controlRow.SetAttr(tomo.AAlign(tomo.AlignEnd, tomo.AlignMiddle))
|
||||
window.SetRoot(NewOuterContainer (
|
||||
layouts.Column { true, false },
|
||||
colorPicker,
|
||||
@@ -155,14 +155,14 @@ func (this *Swatch) userSetValue (value color.Color) {
|
||||
this.on.valueChange.Broadcast()
|
||||
}
|
||||
|
||||
func (this *Swatch) handleKeyUp (key input.Key, numberPad bool) {
|
||||
func (this *Swatch) handleKeyUp (catch func (), key input.Key, numberPad bool) {
|
||||
if key != input.KeyEnter && key != input.Key(' ') { return }
|
||||
this.Choose()
|
||||
}
|
||||
|
||||
func (this *Swatch) handleMouseUp (button input.Button) {
|
||||
func (this *Swatch) handleButtonUp (catch func (), button input.Button) {
|
||||
if button != input.ButtonLeft { return }
|
||||
if this.MousePosition().In(this.Bounds()) {
|
||||
if this.Window().MousePosition().In(this.Bounds()) {
|
||||
this.Choose()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user