diff --git a/slider.go b/slider.go index fff4219..f2ebf32 100644 --- a/slider.go +++ b/slider.go @@ -15,7 +15,7 @@ type Slider struct { dragOffset image.Point on struct { - valueChange event.FuncBroadcaster + slide event.FuncBroadcaster } } @@ -71,7 +71,6 @@ func (this *Slider) SetValue (value float64) { if value == this.layout.value { return } this.layout.value = value this.SetLayout(this.layout) - this.on.valueChange.Broadcast() } // Value returns the value of the slider between 0 and 1. @@ -79,10 +78,10 @@ func (this *Slider) Value () float64 { return this.layout.value } -// OnValueChange specifies a function to be called when the slider's value -// changes. -func (this *Slider) OnValueChange (callback func ()) event.Cookie { - return this.on.valueChange.Connect(callback) +// OnValueChange specifies a function to be called when the user moves the +// slider. +func (this *Slider) OnSlide (callback func ()) event.Cookie { + return this.on.slide.Connect(callback) } func (this *Slider) handleKeyDown (key input.Key, numpad bool) { @@ -139,14 +138,18 @@ func (this *Slider) handleMouseDown (button input.Button) { case input.ButtonMiddle: if above { this.SetValue(0) + this.on.slide.Broadcast() } else { this.SetValue(1) + this.on.slide.Broadcast() } case input.ButtonRight: if above { this.SetValue(this.Value() - 0.05) + this.on.slide.Broadcast() } else { this.SetValue(this.Value() + 0.05) + this.on.slide.Broadcast() } } } @@ -176,6 +179,7 @@ func (this *Slider) drag () { float64(pointer.X) / float64(gutter.Dx() - handle.Dx())) } + this.on.slide.Broadcast() } func (this *Slider) fallbackDragOffset () image.Point {