slint/internal/compiler/widgets/qt/spinbox.slint
Olivier Goffart 3e94bd2167 Janitor: Remove trailing whitespaces from all files
`git grep -I -l -O'sed -i "s/[[:space:]]*$//"' -e ''`
2025-01-10 13:23:22 +01:00

31 lines
1 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
export component SpinBox inherits NativeSpinBox {
value: root.minimum;
accessible-role: spinbox;
accessible-enabled: root.enabled;
accessible-value: root.value;
accessible-value-minimum: root.minimum;
accessible-value-maximum: root.maximum;
accessible-value-step: (root.maximum - root.minimum) / 100;
accessible-action-set-value(v) => { if v.is-float() {update-value(v.to-float());} }
accessible-action-increment => { root.increment(); }
accessible-action-decrement => { root.decrement(); }
function increment() {
root.update-value(root.value + root.step-size);
}
function decrement() {
root.update-value(root.value - root.step-size);
}
function update-value(value: int) {
if (value >= root.minimum && value <= root.maximum) {
root.value = value;
root.edited(value);
}
}
}