Add OnEnter for Slider
This commit is contained in:
parent
a38cee8437
commit
b7d1a0abdd
13
slider.go
13
slider.go
@ -17,6 +17,7 @@ type Slider struct {
|
|||||||
|
|
||||||
on struct {
|
on struct {
|
||||||
slide event.FuncBroadcaster
|
slide event.FuncBroadcaster
|
||||||
|
enter event.FuncBroadcaster
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,6 +90,12 @@ func (this *Slider) OnSlide (callback func ()) event.Cookie {
|
|||||||
return this.on.slide.Connect(callback)
|
return this.on.slide.Connect(callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OnEnter specifies a function to be called when the user stops moving the
|
||||||
|
// slider.
|
||||||
|
func (this *Slider) OnEnter (callback func ()) event.Cookie {
|
||||||
|
return this.on.enter.Connect(callback)
|
||||||
|
}
|
||||||
|
|
||||||
func (this *Slider) handleKeyDown (key input.Key, numpad bool) {
|
func (this *Slider) handleKeyDown (key input.Key, numpad bool) {
|
||||||
var increment float64; if this.layout.vertical {
|
var increment float64; if this.layout.vertical {
|
||||||
increment = -0.05
|
increment = -0.05
|
||||||
@ -148,17 +155,21 @@ func (this *Slider) handleMouseDown (button input.Button) {
|
|||||||
if above {
|
if above {
|
||||||
this.SetValue(0)
|
this.SetValue(0)
|
||||||
this.on.slide.Broadcast()
|
this.on.slide.Broadcast()
|
||||||
|
this.on.enter.Broadcast()
|
||||||
} else {
|
} else {
|
||||||
this.SetValue(1)
|
this.SetValue(1)
|
||||||
this.on.slide.Broadcast()
|
this.on.slide.Broadcast()
|
||||||
|
this.on.enter.Broadcast()
|
||||||
}
|
}
|
||||||
case input.ButtonRight:
|
case input.ButtonRight:
|
||||||
if above {
|
if above {
|
||||||
this.SetValue(this.Value() - this.step)
|
this.SetValue(this.Value() - this.step)
|
||||||
this.on.slide.Broadcast()
|
this.on.slide.Broadcast()
|
||||||
|
this.on.enter.Broadcast()
|
||||||
} else {
|
} else {
|
||||||
this.SetValue(this.Value() + this.step)
|
this.SetValue(this.Value() + this.step)
|
||||||
this.on.slide.Broadcast()
|
this.on.slide.Broadcast()
|
||||||
|
this.on.enter.Broadcast()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -166,6 +177,7 @@ func (this *Slider) handleMouseDown (button input.Button) {
|
|||||||
func (this *Slider) handleMouseUp (button input.Button) {
|
func (this *Slider) handleMouseUp (button input.Button) {
|
||||||
if button != input.ButtonLeft || !this.dragging { return }
|
if button != input.ButtonLeft || !this.dragging { return }
|
||||||
this.dragging = false
|
this.dragging = false
|
||||||
|
this.on.enter.Broadcast()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Slider) handleMouseMove () {
|
func (this *Slider) handleMouseMove () {
|
||||||
@ -177,6 +189,7 @@ func (this *Slider) handleScroll (x, y float64) {
|
|||||||
delta := (x + y) * 0.005
|
delta := (x + y) * 0.005
|
||||||
this.SetValue(this.Value() + delta)
|
this.SetValue(this.Value() + delta)
|
||||||
this.on.slide.Broadcast()
|
this.on.slide.Broadcast()
|
||||||
|
this.on.enter.Broadcast()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Slider) drag () {
|
func (this *Slider) drag () {
|
||||||
|
Loading…
Reference in New Issue
Block a user