Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions core/slider.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ func (sr *Slider) Init() {
})
sr.On(events.Click, func(e events.Event) {
pos := sr.pointToRelPos(e.Pos())
sr.setSliderPosEvent(pos)
if !sr.setSliderPosEvent(pos) {
sr.Send(events.Input) // always send on click even if same.
}
sr.sendChange()
})
sr.On(events.Scroll, func(e events.Event) {
Expand Down Expand Up @@ -401,13 +403,15 @@ func (sr *Slider) setSliderPos(pos float32) {

// setSliderPosEvent sets the position of the slider at the given position in pixels,
// and updates the corresponding Value based on that position.
// This version sends input events.
func (sr *Slider) setSliderPosEvent(pos float32) {
// This version sends input events. Returns true if event sent.
func (sr *Slider) setSliderPosEvent(pos float32) bool {
sr.setSliderPos(pos)
if math32.Abs(sr.prevSlide-sr.Value) > sr.InputThreshold {
sr.prevSlide = sr.Value
sr.Send(events.Input)
return true
}
return false
}

// setPosFromValue sets the slider position based on the given value
Expand Down
Loading