Class WSlider
A slider allows the user to specify an integer value within a particular range using a visual slider.
The slider must be sized explicitly using resize() or by a layout manager. The default size is 150 x 50 pixels for a horizontal slider,
and 50 x 150 pixels for a vertical slider.
Horizontal slider with ticks on both sides.
CSS
The non-native slider (HTML4, see setNativeControl()) is styled by the current CSS theme.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumeration that specifies the location of ticks.Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static Stringstatic final EnumSet<WSlider.TickPosition>static final EnumSet<WSlider.TickPosition>Fields inherited from class eu.webtoolkit.jwt.WInteractWidget
dragTouchEndSlot_, dragTouchSlot_, noDefault -
Constructor Summary
ConstructorsConstructorDescriptionWSlider()Creates a default horizontal slider.WSlider(Orientation orientation) Creates a default slider of the given orientation.WSlider(Orientation orientation, WContainerWidget parentContainer) Creates a default slider of the given orientation.WSlider(WContainerWidget parentContainer) Creates a default horizontal slider. -
Method Summary
Modifier and TypeMethodDescriptionvoidProgresses to an Ajax-enabled widget.protected WInteractWidgetCreates the handle (for a non-native widget)intReturns the handle width.intReturns the maximum value.intReturns the minimum value.Returns the slider orientation.intgetStep()Return the step value.intReturns the tick interval.Returns the tick length.Returns the tick position.intgetValue()Returns the current slider value.Returns the current value.input()Signal emitted when input was captured.booleanReturns whether a native HTML5 control is used.protected voidlayoutSizeChanged(int width, int height) Virtual method that indicates a size change.protected voidPaints a slider ticks (for a non-native widget)voidremove()Destructor.protected voidrender(EnumSet<RenderFlag> flags) Renders the widget.voidResizes the widget.voidsetDisabled(boolean disabled) Sets whether the widget is disabled.protected voidsetFormData(WObject.FormData formData) voidsetHandleWidth(int handleWidth) Sets the slider handle width.voidsetMaximum(int maximum) Sets the maximum value.voidsetMinimum(int minimum) Sets the minimum value.voidsetNativeControl(boolean nativeControl) Configures whether a native HTML5 control should be used.voidsetOrientation(Orientation orientation) Sets the slider orientation.voidsetRange(int minimum, int maximum) Sets the value range.voidsetStep(int step) Sets the step value.voidsetTickInterval(int tickInterval) Sets the tick interval.voidsetTickLength(WLength length) Sets the length of the ticks to be drawn.final voidsetTickPosition(WSlider.TickPosition tickPositio, WSlider.TickPosition... tickPosition) Sets the tick position.voidsetTickPosition(EnumSet<WSlider.TickPosition> tickPosition) Sets the tick position.voidsetValue(int value) Sets the slider value.voidsetValueText(String value) Sets the value text.Signal emitted while the user drags the slider.Signal emitted when the user has changed the value of the slider.Methods inherited from class eu.webtoolkit.jwt.WFormWidget
changed, getLabel, getPlaceholderText, getRealValidator, getTabIndex, getValidator, hasValidatorChanged, isCanReceiveFocus, isReadOnly, propagateSetEnabled, refresh, setEnabled, setHidden, setPlaceholderText, setReadOnly, setToolTip, setValidator, validate, validated, validatorChangedMethods inherited from class eu.webtoolkit.jwt.WInteractWidget
clicked, doubleClicked, enterPressed, escapePressed, gestureChanged, gestureEnded, gestureStarted, getMouseOverDelay, isEnabled, keyPressed, keyWentDown, keyWentUp, load, mouseDragged, mouseMoved, mouseWentDown, mouseWentOut, mouseWentOver, mouseWentUp, mouseWheel, setDraggable, setDraggable, setDraggable, setDraggable, setMouseOverDelay, setPopup, touchEnded, touchMoved, touchStarted, unsetDraggableMethods inherited from class eu.webtoolkit.jwt.WWebWidget
addStyleClass, beingDeleted, blurred, callJavaScriptMember, childrenChanged, createDomElement, doJavaScript, escapeText, escapeText, escapeText, escapeText, find, findById, focussed, getAttributeValue, getBaseZIndex, getChildren, getClearSides, getDecorationStyle, getDomChanges, getFloatSide, getHeight, getHtmlTagName, getId, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getScrollVisibilityMargin, getStyleClass, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, hasFocus, hasStyleClass, hideToolTip, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isScrollVisibilityEnabled, isScrollVisible, isSetFirstFocus, isThemeStyleEnabled, isVisible, iterateChildren, jsStringLiteral, jsStringLiteral, manageWidget, parentResized, parentResized, propagateSetVisible, removeScript, removeStyleClass, scrollVisibilityChanged, setAttributeValue, setBaseZIndex, setCanReceiveFocus, setClearSides, setDecorationStyle, setDeferredToolTip, setFlexBox, setFloatSide, setFocus, setHiddenKeepsGeometry, setHtmlTagName, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setObjectName, setOffsets, setParentWidget, setPositionScheme, setScrollVisibilityEnabled, setScrollVisibilityMargin, setSelectable, setStyleClass, setTabIndex, setThemeStyleEnabled, setVerticalAlignment, showToolTip, showToolTipOnHover, unescapeText, updateSignalConnection, voidEventSignal, widgetAdded, widgetRemovedMethods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, applyThemeStyles, boxBorder, boxPadding, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, needsRerender, positionAt, positionAt, positionAt, positionAt, removeFromParent, removeStyleClass, removeWidget, render, resize, scheduleRender, scheduleRender, scheduleRender, scheduleThemeStyleApply, setClearSides, setDeferredToolTip, setFocus, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, trMethods inherited from class eu.webtoolkit.jwt.WObject
getObjectName
-
Field Details
-
NoTicks
-
TicksBothSides
-
INPUT_SIGNAL
-
-
Constructor Details
-
WSlider
Creates a default horizontal slider.The slider shows no ticks, has a range from 0 to 99, and has tickInterval of 0 (defaulting to three ticks over the whole range).
The initial value is 0.
-
WSlider
public WSlider()Creates a default horizontal slider. -
WSlider
Creates a default slider of the given orientation.The slider shows no ticks, has a range from 0 to 99, and has tickInterval of 0 (defaulting to three ticks over the whole range).
The initial value is 0.
-
WSlider
Creates a default slider of the given orientation.
-
-
Method Details
-
remove
public void remove()Destructor.- Overrides:
removein classWFormWidget- See Also:
-
setNativeControl
public void setNativeControl(boolean nativeControl) Configures whether a native HTML5 control should be used.When
native, the new "range" input element, specified by HTML5 and when implemented by the browser, is used rather than the built-in element. A native control is styled by the browser (usually in sync with the OS) rather than through the theme chosen. Settings like tick interval and tick position are ignored.Note: Vertically oriented sliders are in theory supported by the HTML5 input element, but in practice are usually not rendered correctly by the browser.
-
isNativeControl
public boolean isNativeControl()Returns whether a native HTML5 control is used.Taking into account the preference for a native control, configured using
setNativeControl(), this method returns whether a native control is actually being used. -
setOrientation
Sets the slider orientation.- See Also:
-
getOrientation
Returns the slider orientation.- See Also:
-
setTickInterval
public void setTickInterval(int tickInterval) Sets the tick interval.The tick interval specifies the interval for placing ticks along the slider. The interval is specified in value units (not pixel units). A value of 0 specifies an automatic tick interval, which defaults to 3 ticks spanning the whole range.
-
getTickInterval
public int getTickInterval()Returns the tick interval.- See Also:
-
setTickPosition
Sets the tick position.The tick position indicates if and where ticks are placed around the slider groove.
This function has no effect if the native widget is used.
-
setTickPosition
public final void setTickPosition(WSlider.TickPosition tickPositio, WSlider.TickPosition... tickPosition) Sets the tick position.Calls
setTickPosition(EnumSet.of(tickPositio, tickPosition)) -
getTickPosition
Returns the tick position. -
setTickLength
Sets the length of the ticks to be drawn.This length will be either the width or height when the slider is oriented vertically or horizontally respectively.
This function has no effect if the native widget is used.
- See Also:
-
getTickLength
Returns the tick length.- See Also:
-
setValue
public void setValue(int value) Sets the slider value.The value is automatically trimmed to the valid range (
getMinimum()togetMaximum()).- See Also:
-
getValue
public int getValue()Returns the current slider value.- See Also:
-
setMaximum
public void setMaximum(int maximum) Sets the maximum value.The maximum value defines the upper limit of the valid range. The lower limit and current value are automatically adjusted to remain valid.
-
getMaximum
public int getMaximum()Returns the maximum value.- See Also:
-
setMinimum
public void setMinimum(int minimum) Sets the minimum value.The minimum value defines the lower limit of the valid range. The upper limit and current value are automatically adjusted to remain valid.
-
getMinimum
public int getMinimum()Returns the minimum value.- See Also:
-
setRange
public void setRange(int minimum, int maximum) Sets the value range. -
getStep
public int getStep()Return the step value.The default value of the step is
1.- See Also:
-
setStep
public void setStep(int step) Sets the step value.This is a positive integer value that indicates by which step the slider moves between the minimum and maximum.
It is not necessary that the slider's range can be neatly divided by the step value. Meaning a range of 50 (0 - 50), with a step of 7, is possible, but will never reach the maximum value.
- See Also:
-
valueChanged
Signal emitted when the user has changed the value of the slider.The new value is passed as the argument.
- See Also:
-
sliderMoved
Signal emitted while the user drags the slider.The current dragged position is passed as the argument. Note that the slider value is not changed while dragging the slider, but only after the slider has been released.
- See Also:
-
setHandleWidth
public void setHandleWidth(int handleWidth) Sets the slider handle width.This sets the width for the handle, which is needed to accurately position the handle.
The default value is 20 pixels.
-
getHandleWidth
public int getHandleWidth()Returns the handle width.- See Also:
-
input
Signal emitted when input was captured.The signal is only emitted when keyboard input (arrow keys) are captured.
-
setDisabled
public void setDisabled(boolean disabled) Description copied from class:WWidgetSets whether the widget is disabled.The widget can be set to being disabled, or enabled. This state will also be propagated to all its descendants. Those descendants will only be "visually" made disabled, their actual
isDisabled()state will remain unaltered. All descendants will be assigned the disabled styleclass, which is dependent on the used Theme.The
isDisabled()check will thus only returntruein case setDisabled(true) has been called on the widget before. If the anscestor of a widget has been marked setDisabled(true), the widget'sisDisabled()state will remainfalse.To check if a widget has been passively disabled, by one of its anscestors, use
isEnabled().Typically, a disabled form widget will not allow changing the value, and disabled widgets will not react to mouse click events.
- Overrides:
setDisabledin classWWebWidget- See Also:
-
resize
Description copied from class:WWidgetResizes the widget.Specifies a fixed size for this widget, setting CSS
widthandheightproperties. By default a widget has automatic width and height, which sets a size for the widget following CSS rules.When the widget is not managed by a layout manager, the automatic (natural) size of a widget depends on whether the widget is a block or inline widget:
- a block widget takes by default the width of the parent, and the height that it needs based on its contents
- an inline widget takes the width and height that it needs based on its contents (possibly wrapping over multiple lines). The width and height of an inline widget cannot be changed (by the letter of CSS, although most browsers will react to it in varying ways).
When inserted in a layout manager, the size set will be used as a widget's preferred size, but the widget may be given a different size by the layout manager based on available space and stretch factors. The actual size given by a layout manager may be retrieved by making the widget "layout size aware", using
setLayoutSizeAware(). If you have defined a"wtResize()"JavaScript method for the widget, then this method will also be called.The default width and height of a widget is
WLength.Auto.- Overrides:
resizein classWWebWidget- See Also:
-
getValueText
Description copied from class:WFormWidgetReturns the current value.This returns the current value as a string.
- Specified by:
getValueTextin classWFormWidget
-
setValueText
Description copied from class:WFormWidgetSets the value text.This sets the current value from a string value.
- Specified by:
setValueTextin classWFormWidget
-
enableAjax
public void enableAjax()Description copied from class:WWidgetProgresses to an Ajax-enabled widget.This method is called when the progressive bootstrap method is used, and support for AJAX has been detected. The default behavior will upgrade the widget's event handling to use AJAX instead of full page reloads, and propagate the call to its children.
You may want to reimplement this method if you want to make changes to widget when AJAX is enabled. You should always call the base implementation.
- Overrides:
enableAjaxin classWFormWidget- See Also:
-
paintTick
Paints a slider ticks (for a non-native widget)The default implementation draws ticks taking into account the the tickPosition.
The mid point for the tick should be at position (x, y). The
valuethat corresponds to the tick is also passed. -
getCreateHandle
Creates the handle (for a non-native widget)The default implementation creates a container widget. You may want to specialize this function if you want to have more control on the handle appearance or if you want to associate with the handle a tooltip or other information (e.g. a popup balloon).
-
layoutSizeChanged
protected void layoutSizeChanged(int width, int height) Description copied from class:WWidgetVirtual method that indicates a size change.This method propagates the client-side width and height of the widget when the widget is contained by a layout manager and setLayoutSizeAware(true) was called.
- Overrides:
layoutSizeChangedin classWWidget- See Also:
-
render
Description copied from class:WWidgetRenders the widget.This function renders the widget (or an update for the widget), after this has been scheduled using
scheduleRender().The default implementation will render the widget by serializing changes to JavaScript and HTML. You may want to reimplement this widget if you have been postponing some of the layout / rendering implementation until the latest moment possible. In that case you should make sure you call the base implementation however.
- Overrides:
renderin classWFormWidget
-
setFormData
- Overrides:
setFormDatain classWObject
-