Jazz2::UI::Windows::NumberBox class

Number that can be dragged or typed.

Base classes

class TextBox
Single line of text that can be edited.

Constructors, destructors, conversion operators

NumberBox(Function<float()>&& getter, Function<void(float, bool)>&& setter, float minValue, float maxValue, float step = 1.0f, std::int32_t decimals = 0)
Creates a new instance.

Public functions

void Draw(Painter& painter) override
Draws the element and its children.
auto OnPointerDown(const PointerEvent& event) -> bool override
Called when the pointer is pressed over the element, returns true to keep getting it until released.
void OnPointerMove(const PointerEvent& event) override
Called when the pointer moves while pressed over the element.
void OnPointerUp(const PointerEvent& event, bool inside) override
Called when the pointer is released, inside tells whether it's still over the element.
void OnPointerCancel() override
Called instead of OnPointerUp() when the press was taken away, such as by a finger scrolling the list it's in.
auto OnWheel(const PointerEvent& event) -> bool override
Called when the pointer is scrolled over the element, returns true if it was used.
auto IsFocusable() const -> bool override
A click doesn't type into it, the number is dragged or stepped then, it's typed into by a click without moving, see BeginEdit().
auto IsTabStop() const -> bool override
Reached by Tab to type the number, Up and Down step it then.
auto OnKeyPressed(const KeyboardEvent& event) -> bool override
Called when a key is pressed while the element has the focus, returns true if it was used.
void StepBy(float steps)
Changes the value by a number of steps, as the arrows at its edge do.

Public variables

Function<float()> Getter
Returns the value.
Function<void(float, bool)> Setter
Sets the value, the flag tells whether it's final or only shown while dragged.
float MinValue
Smallest value.
float MaxValue
Largest value.
float Step
Change of the value for one unit of dragging.
std::int32_t Decimals
Number of decimal places shown.
Function<float()> DefaultValue
Returns the value the middle button (the wheel pressed) resets it to, it isn't reset if empty.