Slider

Extends: UiWidget

A horizontal value picker: a label, a filled bar, and a numeric readout. Adjust with increase()/decrease() (step-sized) or set an exact value with setValue().

Properties

  • minValue (float)
  • maxValue (float)
  • step (float)
  • value (float)
  • repeatThrottle (BGE.UI.RepeatThrottle) — Throttles repeat-while-held Left/Right to one step per ' WIDGET_REPEAT_DELAY_MS - see handleInput().
  • barColor (dynamic)
  • backgroundColor (dynamic)
  • drawableText (BGE.DrawableText)

Constructor

new Slider(game: BGE.Game): Slider

Parameters


Instance Methods

setLabel(text: string): void

Sets a label to show alongside the value (e.g. "Volume")

Parameters

  • text (string)

Returns

  • void

getValue(): float

Gets the slider's current value

Returns

  • float

setValue(newValue: float): void

Sets the slider's value, clamped to [minValue, maxValue]

Parameters

  • newValue (float)

Returns

  • void

increase(amount?: float): void

Increases the value by step (or a given amount), clamped to maxValue

Parameters

  • amount (float, optional, default: "invalid") — defaults to m.step

Returns

  • void

decrease(amount?: float): void

Decreases the value by step (or a given amount), clamped to minValue

Parameters

  • amount (float, optional, default: "invalid") — defaults to m.step

Returns

  • void

handleInput(input: BGE.GameInput): boolean

Left/Right (while this slider is focused) adjust the value by step and consume the event, so it doesn't also reach GameEntity.onInput() - see GameInput.consume(). Called only while focused - see UiWidget.handleInput()/UiContainer.updateFocusChain(). A held Left/Right event is always consumed too - Game.bs synthesizes one alongside every press, and it has to be consumed rather than leaking through - but it only ADJUSTS once WIDGET_REPEAT_DELAY_MS has passed since the last step, so a single tap's press+held pair steps exactly once while a sustained hold still repeats.

Parameters

Returns

  • boolean

draw(parent?: UiWidget): void

Parameters

  • parent (UiWidget, optional, default: "invalid")

Returns

  • void