mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-10 05:39:16 +00:00
29 lines
No EOL
974 B
Text
29 lines
No EOL
974 B
Text
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
|
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
|
|
|
|
export component Slider inherits NativeSlider {
|
|
out property <bool> has-focus: i-focus-scope.has-focus;
|
|
|
|
accessible-role: slider;
|
|
accessible-value: root.value;
|
|
accessible-value-minimum: root.minimum;
|
|
accessible-value-maximum: root.maximum;
|
|
accessible-value-step: (root.maximum - root.minimum) / 100;
|
|
|
|
i-focus-scope := FocusScope {
|
|
x: 0;
|
|
width: 0;
|
|
|
|
key-pressed(event) => {
|
|
if (root.enabled && event.text == Key.RightArrow) {
|
|
root.value = Math.min(root.value + 1, root.maximum);
|
|
accept
|
|
} else if (root.enabled && event.text == Key.LeftArrow) {
|
|
root.value = Math.max(root.value - 1, root.minimum);
|
|
accept
|
|
} else {
|
|
reject
|
|
}
|
|
}
|
|
}
|
|
} |