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 9fb168973..cf4b39e21 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 @@ -51,6 +51,8 @@ public class NebulaSlider extends Canvas { private IntFunction format; + private int movingValue; + /** * Constructs a new instance of this class given its parent and a style value * describing its behavior and appearance. @@ -229,12 +231,16 @@ private void addMouseListeners() { return; } moving = true; + movingValue = value; mouseDeltaX = xPosition - e.x; }); addListener(SWT.MouseUp, e -> { moving = false; mouseDeltaX = 0; + if(movingValue != value) { + SelectionListenerUtil.fireDefaultSelectionListeners(this, e); + } redraw(); }); diff --git a/widgets/opal/commons/org.eclipse.nebula.widgets.opal.commons/src/org/eclipse/nebula/widgets/opal/commons/SelectionListenerUtil.java b/widgets/opal/commons/org.eclipse.nebula.widgets.opal.commons/src/org/eclipse/nebula/widgets/opal/commons/SelectionListenerUtil.java index 2b8009343..661fb9549 100644 --- a/widgets/opal/commons/org.eclipse.nebula.widgets.opal.commons/src/org/eclipse/nebula/widgets/opal/commons/SelectionListenerUtil.java +++ b/widgets/opal/commons/org.eclipse.nebula.widgets.opal.commons/src/org/eclipse/nebula/widgets/opal/commons/SelectionListenerUtil.java @@ -65,7 +65,23 @@ public static void removeSelectionListener(final Control control, final Selectio * @return true if the selection could be changed, false otherwise */ public static boolean fireSelectionListeners(final Control control, final Event sourceEvent) { - for (final Listener listener : control.getListeners(SWT.Selection)) { + return fireSelectionListenersEvent(control, sourceEvent, SWT.Selection); + } + + /** + * Fire the default selection listeners of a given control + * + * @param control the control that fires the event + * @param sourceEvent mouse event + * @return true if the selection could be changed, false otherwise + */ + public static boolean fireDefaultSelectionListeners(final Control control, final Event sourceEvent) { + return fireSelectionListenersEvent(control, sourceEvent, SWT.DefaultSelection); + } + + private static boolean fireSelectionListenersEvent(final Control control, final Event sourceEvent, int type) { + Listener[] listeners = control.getListeners(SWT.Selection); + for(final Listener listener : listeners) { final Event event = new Event(); event.button = sourceEvent==null?1:sourceEvent.button; @@ -76,7 +92,7 @@ public static boolean fireSelectionListeners(final Control control, final Event event.time = sourceEvent == null ? 0 : sourceEvent.time; event.x = sourceEvent == null ? 0 : sourceEvent.x; event.y = sourceEvent == null ? 0 : sourceEvent.y; - event.type = SWT.Selection; + event.type = type; listener.handleEvent(event); if (!event.doit) {