Update code for objects
This commit is contained in:
24
swatch.go
24
swatch.go
@@ -30,7 +30,9 @@ func NewSwatch (value color.Color) *Swatch {
|
||||
swatch.SetDrawer(swatch)
|
||||
swatch.SetValue(value)
|
||||
|
||||
swatch.OnButtonDown(swatch.handleButtonDown)
|
||||
swatch.OnButtonUp(swatch.handleButtonUp)
|
||||
swatch.OnKeyDown(swatch.handleKeyDown)
|
||||
swatch.OnKeyUp(swatch.handleKeyUp)
|
||||
swatch.SetFocusable(true)
|
||||
return swatch
|
||||
@@ -155,14 +157,26 @@ func (this *Swatch) userSetValue (value color.Color) {
|
||||
this.on.valueChange.Broadcast()
|
||||
}
|
||||
|
||||
func (this *Swatch) handleKeyUp (catch func (), key input.Key, numberPad bool) {
|
||||
if key != input.KeyEnter && key != input.Key(' ') { return }
|
||||
this.Choose()
|
||||
func (this *Swatch) handleKeyDown (key input.Key, numberPad bool) bool {
|
||||
if key != input.KeyEnter && key != input.Key(' ') { return false }
|
||||
return true
|
||||
}
|
||||
|
||||
func (this *Swatch) handleButtonUp (catch func (), button input.Button) {
|
||||
if button != input.ButtonLeft { return }
|
||||
func (this *Swatch) handleKeyUp (key input.Key, numberPad bool) bool {
|
||||
if key != input.KeyEnter && key != input.Key(' ') { return false }
|
||||
this.Choose()
|
||||
return true
|
||||
}
|
||||
|
||||
func (this *Swatch) handleButtonDown (button input.Button) bool {
|
||||
if button != input.ButtonLeft { return false }
|
||||
return true
|
||||
}
|
||||
|
||||
func (this *Swatch) handleButtonUp (button input.Button) bool {
|
||||
if button != input.ButtonLeft { return false }
|
||||
if this.Window().MousePosition().In(this.Bounds()) {
|
||||
this.Choose()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user