summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorAnastasia Smirnova <anasmi@utu.fi>2019-04-10 16:17:18 +0300
committerSun Zhe <31067185+ZheSun88@users.noreply.github.com>2019-04-10 16:17:18 +0300
commit258450a82b61b1582905978433b8ed23575924b8 (patch)
treea410f391ff9889e475a88b94bad4c7e24c73d49f /client
parent7392bf241f115a9a338e047187be1b1d1ddfaed6 (diff)
downloadvaadin-framework-258450a82b61b1582905978433b8ed23575924b8.tar.gz
vaadin-framework-258450a82b61b1582905978433b8ed23575924b8.zip
Clicking on slider makes handler move (#11519)
* Clicking on slider makes handler move Fixes #1496 * Introducing control over clicking behaviour - User will have to enable process of the click event on handle calling `slider.setEnableClickHandler(true);` - Clean-up the handler logic in VSlider.java - Renaming the property to `updateValueOnClick` - Added JavaDocs - Fixing tests
Diffstat (limited to 'client')
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VSlider.java29
-rw-r--r--client/src/main/java/com/vaadin/client/ui/slider/SliderConnector.java1
2 files changed, 22 insertions, 8 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/VSlider.java b/client/src/main/java/com/vaadin/client/ui/VSlider.java
index de805ba423..2f3e56ae61 100644
--- a/client/src/main/java/com/vaadin/client/ui/VSlider.java
+++ b/client/src/main/java/com/vaadin/client/ui/VSlider.java
@@ -58,6 +58,8 @@ public class VSlider extends SimpleFocusablePanel
protected double max;
protected int resolution;
protected Double value;
+
+ private boolean updateValueOnClick;
protected SliderOrientation orientation = SliderOrientation.HORIZONTAL;
private final HTML feedback = new HTML("", false);
@@ -266,12 +268,15 @@ public class VSlider extends SimpleFocusablePanel
processMouseWheelEvent(event);
} else if (dragging || targ == handle) {
processHandleEvent(event);
+ } else if (targ.equals(base)
+ && DOM.eventGetType(event) == Event.ONMOUSEUP
+ && updateValueOnClick) {
+ processBaseEvent(event);
+ feedbackPopup.show();
} else if (targ == smaller) {
decreaseValue(true);
} else if (targ == bigger) {
increaseValue(true);
- } else if (DOM.eventGetType(event) == Event.MOUSEEVENTS) {
- processBaseEvent(event);
} else if (isNavigationEvent(event)) {
if (handleNavigation(event.getKeyCode(), event.getCtrlKey(),
@@ -300,7 +305,8 @@ public class VSlider extends SimpleFocusablePanel
}
private boolean isNavigationEvent(Event event) {
- if (BrowserInfo.get().isGecko() && BrowserInfo.get().getGeckoVersion() < 65) {
+ if (BrowserInfo.get().isGecko()
+ && BrowserInfo.get().getGeckoVersion() < 65) {
return DOM.eventGetType(event) == Event.ONKEYPRESS;
} else {
return DOM.eventGetType(event) == Event.ONKEYDOWN;
@@ -363,11 +369,9 @@ public class VSlider extends SimpleFocusablePanel
}
private void processBaseEvent(Event event) {
- if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
- if (!disabled && !readonly && !dragging) {
- setValueByEvent(event, true);
- DOM.eventCancelBubble(event, true);
- }
+ if (!disabled && !readonly && !dragging) {
+ setValueByEvent(event, true);
+ DOM.eventCancelBubble(event, true);
}
}
@@ -671,4 +675,13 @@ public class VSlider extends SimpleFocusablePanel
}
return null;
}
+
+ /**
+ * Specifies whether or not click event should update the Slider's value.
+ *
+ * @param updateValueOnClick
+ */
+ public void setUpdateValueOnClick(boolean updateValueOnClick) {
+ this.updateValueOnClick = updateValueOnClick;
+ }
}
diff --git a/client/src/main/java/com/vaadin/client/ui/slider/SliderConnector.java b/client/src/main/java/com/vaadin/client/ui/slider/SliderConnector.java
index a5be9b3a2d..f5f220f43f 100644
--- a/client/src/main/java/com/vaadin/client/ui/slider/SliderConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/slider/SliderConnector.java
@@ -82,6 +82,7 @@ public class SliderConnector extends AbstractFieldConnector
getWidget().setMaxValue(getState().maxValue);
getWidget().setResolution(getState().resolution);
getWidget().setValue(getState().value, false);
+ getWidget().setUpdateValueOnClick(getState().updateValueOnClick);
getWidget().buildBase();
getWidget().setTabIndex(getState().tabIndex);