Skip to content

Commit

Permalink
Only fire a selection event when the value changes
Browse files Browse the repository at this point in the history
Currently the NebulaSlider fires a selection event on each move even if
the value has not change numerically.

This first checks if the value has actually changed before event
firing.
  • Loading branch information
laeubi committed Mar 16, 2024
1 parent 27bfb29 commit 2659986
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,13 @@ private void addMouseListeners() {

// Update value
final float ratio = (float) xPosition / originalWidth;
value = (int) Math.floor(ratio * (maximum - minimum));

SelectionListenerUtil.fireSelectionListeners(this,e);
int value = (int)Math.floor(ratio * (maximum - minimum));
if(this.value != value) {
this.value = value;
SelectionListenerUtil.fireSelectionListeners(this, e);
}
redraw();

});
}

Expand Down

0 comments on commit 2659986

Please sign in to comment.