Slider has an OnSlide method instead of OnValueChange
This commit is contained in:
parent
1ff9982e01
commit
a0fe7bc00f
16
slider.go
16
slider.go
@ -15,7 +15,7 @@ type Slider struct {
|
|||||||
dragOffset image.Point
|
dragOffset image.Point
|
||||||
|
|
||||||
on struct {
|
on struct {
|
||||||
valueChange event.FuncBroadcaster
|
slide event.FuncBroadcaster
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,6 @@ func (this *Slider) SetValue (value float64) {
|
|||||||
if value == this.layout.value { return }
|
if value == this.layout.value { return }
|
||||||
this.layout.value = value
|
this.layout.value = value
|
||||||
this.SetLayout(this.layout)
|
this.SetLayout(this.layout)
|
||||||
this.on.valueChange.Broadcast()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Value returns the value of the slider between 0 and 1.
|
// Value returns the value of the slider between 0 and 1.
|
||||||
@ -79,10 +78,10 @@ func (this *Slider) Value () float64 {
|
|||||||
return this.layout.value
|
return this.layout.value
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnValueChange specifies a function to be called when the slider's value
|
// OnValueChange specifies a function to be called when the user moves the
|
||||||
// changes.
|
// slider.
|
||||||
func (this *Slider) OnValueChange (callback func ()) event.Cookie {
|
func (this *Slider) OnSlide (callback func ()) event.Cookie {
|
||||||
return this.on.valueChange.Connect(callback)
|
return this.on.slide.Connect(callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Slider) handleKeyDown (key input.Key, numpad bool) {
|
func (this *Slider) handleKeyDown (key input.Key, numpad bool) {
|
||||||
@ -139,14 +138,18 @@ func (this *Slider) handleMouseDown (button input.Button) {
|
|||||||
case input.ButtonMiddle:
|
case input.ButtonMiddle:
|
||||||
if above {
|
if above {
|
||||||
this.SetValue(0)
|
this.SetValue(0)
|
||||||
|
this.on.slide.Broadcast()
|
||||||
} else {
|
} else {
|
||||||
this.SetValue(1)
|
this.SetValue(1)
|
||||||
|
this.on.slide.Broadcast()
|
||||||
}
|
}
|
||||||
case input.ButtonRight:
|
case input.ButtonRight:
|
||||||
if above {
|
if above {
|
||||||
this.SetValue(this.Value() - 0.05)
|
this.SetValue(this.Value() - 0.05)
|
||||||
|
this.on.slide.Broadcast()
|
||||||
} else {
|
} else {
|
||||||
this.SetValue(this.Value() + 0.05)
|
this.SetValue(this.Value() + 0.05)
|
||||||
|
this.on.slide.Broadcast()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,6 +179,7 @@ func (this *Slider) drag () {
|
|||||||
float64(pointer.X) /
|
float64(pointer.X) /
|
||||||
float64(gutter.Dx() - handle.Dx()))
|
float64(gutter.Dx() - handle.Dx()))
|
||||||
}
|
}
|
||||||
|
this.on.slide.Broadcast()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Slider) fallbackDragOffset () image.Point {
|
func (this *Slider) fallbackDragOffset () image.Point {
|
||||||
|
Loading…
Reference in New Issue
Block a user