Slider
classin packageklyn.gui.windows
public class Slider extends Widget:
└ Slider

Integer slider widget.

The native backend forwards pointer presses and drags to setValueFromPoint, so the widget remains implemented in Klyn while only the platform event routing stays native.

slider = Slider(value=50, minimum=0, maximum=100, orientation=Slider.HORIZONTAL)
slider.trackFillColor = Color(59, 142, 208, 1.0)
slider.valueChanged += lambda(event: ValueChangedEvent): print(event.value)
Fields
Modifier and Type Member Description
public static const HORIZONTAL
HORIZONTAL as String = "horizontal"
No summary.
public static const VERTICAL
VERTICAL as String = "vertical"
No summary.
public event valueChanged
valueChanged as Event
Emitted after the value changes.
Properties
Modifier and Type Member Description
public property liveValue
liveValue as Boolean:
Whether the current value is displayed next to the thumb during drag.
public property maximum
maximum as Int = 100
Highest allowed value.
public property minimum
minimum as Int = 0
Lowest allowed value.
public property orientation
orientation as String = Slider.HORIZONTAL
Slider orientation: `horizontal` or `vertical`.
public property showTicks
showTicks as Boolean:
Whether the slider paints graduations along its scale.
public property showValues
showValues as Boolean:
Whether numeric values are painted near the ticks.
public property tickInterval
tickInterval as Int:
Distance between two tick marks and displayed values.
public property trackFillColor
trackFillColor as Color:
Color used for the active track segment between `minimum` and `value`.
public property value
value as Int:
Current value, clamped between `minimum` and `maximum`.
Properties inherited from Widget: accentColor, backgroundColor, borderColor, bottom, canFocus, cornerRadius, font, foregroundColor, hasFocus, height, isEnabled, isHovered, isManaged, isVisible, layoutParams, margin, maxHeight, maxWidth, minHeight, minWidth, parent, preferredHeight, preferredWidth, right, sizePolicy, styleClass, width, window, x, y
Constructors
Modifier and Type Member Description
public Slider
Slider(orientation as String, value as Int = 50, minimum as Int = 0, maximum as Int = 100):
Creates a slider with an explicit orientation and optional range.
public Slider
Slider(value as Int = 50, minimum as Int = 0, maximum as Int = 100, orientation as String = Slider.HORIZONTAL):
Creates a slider with an initial value, range, and orientation.
Methods
Modifier and Type Member Description
public adjustValueBy
adjustValueBy(delta as Int) as Void:
Adjusts the current value by a signed delta.
public beginDrag
beginDrag() as Void:
Native backend hook called when a pointer drag starts on this slider.
public clampValue
clampValue(value as Int) as Int:
Clamps a value into the slider range.
public endDrag
endDrag() as Void:
Native backend hook called when a pointer drag ends on this slider.
public override paint
paint(painter as Painter) as Void:
Paints the slider track, optional scale, optional live value, and thumb.
public setValue
setValue(value as Int) as Void:
Sets the value and emits `valueChanged` when it changes.
public setValueFromPoint
setValueFromPoint(x as Int, y as Int) as Void:
Updates the value from a window-relative pointer position.
Methods inherited from Widget: blur, containsPoint, paint, repaint, requestFocus, resolvePreferredHeight, resolvePreferredWidth, resolvedFont, setBounds