slint/internal/compiler/widgets/qt/spinbox.slint
Dirley Jordan 35b9c1e738
Fix a positive minimum causing an incorrect slider/spinbox value (#5148)
sets the default value to that of the minimum
2024-04-30 09:30:31 +02:00

22 lines
No EOL
859 B
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.2 OR LicenseRef-Slint-commercial
export component SpinBox inherits NativeSpinBox {
value: root.minimum;
accessible-role: spinbox;
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 => { update-value(root.value + 1); }
accessible-action-decrement => { update-value(root.value - 1); }
function update-value(value: int) {
if (value >= root.minimum && value <= root.maximum) {
root.value = value;
root.edited(value);
}
}
}