From 26599867b84e9bde8e1e47ee405f9918066c83dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Sat, 16 Mar 2024 07:35:07 +0100 Subject: [PATCH] Only fire a selection event when the value changes 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. --- .../nebula/widgets/opal/nebulaslider/NebulaSlider.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/widgets/nebulaslider/org.eclipse.nebula.widgets.nebulaslider/src/org/eclipse/nebula/widgets/opal/nebulaslider/NebulaSlider.java b/widgets/nebulaslider/org.eclipse.nebula.widgets.nebulaslider/src/org/eclipse/nebula/widgets/opal/nebulaslider/NebulaSlider.java index 88c34179a..9fb168973 100644 --- a/widgets/nebulaslider/org.eclipse.nebula.widgets.nebulaslider/src/org/eclipse/nebula/widgets/opal/nebulaslider/NebulaSlider.java +++ b/widgets/nebulaslider/org.eclipse.nebula.widgets.nebulaslider/src/org/eclipse/nebula/widgets/opal/nebulaslider/NebulaSlider.java @@ -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(); + }); }