mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 02:39:28 +00:00
Do not eat all keypresses in SpinBox
This commit is contained in:
parent
626f7c64fc
commit
24d325a53b
2 changed files with 12 additions and 6 deletions
|
@ -1,6 +1,8 @@
|
|||
// Copyright © SixtyFPS GmbH <info@slint-ui.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
|
||||
|
||||
// cSpell: ignore standardbutton
|
||||
|
||||
import { LineEditInner, TextEdit, AboutSlint } from "../common/common.slint";
|
||||
import { StandardButton } from "../common/standardbutton.slint";
|
||||
import { StyleMetrics, ScrollView, Button, Palette } from "std-widgets-impl.slint";
|
||||
|
@ -163,14 +165,17 @@ export SpinBox := FocusScope {
|
|||
: has-focus ? Palette.themeSecondary
|
||||
: Palette.neutralDark;
|
||||
}
|
||||
|
||||
|
||||
key-pressed(event) => {
|
||||
if (enabled && event.text == Keys.UpArrow && value < maximum) {
|
||||
value += 1;
|
||||
accept
|
||||
} else if (enabled && event.text == Keys.DownArrow && value > minimum) {
|
||||
value -= 1;
|
||||
accept
|
||||
} else {
|
||||
reject
|
||||
}
|
||||
accept
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ export StandardButton := NativeButton {
|
|||
export CheckBox := NativeCheckBox { }
|
||||
export SpinBox := NativeSpinBox {
|
||||
property<length> font-size;
|
||||
|
||||
|
||||
key-pressed(event) => {
|
||||
if (enabled && event.text == Keys.UpArrow && value < maximum) {
|
||||
value += 1;
|
||||
|
@ -84,12 +84,13 @@ export StandardListView := ListView {
|
|||
key-pressed(event) => {
|
||||
if (event.text == Keys.UpArrow && current-item > 0) {
|
||||
actual-current-item -= 1;
|
||||
return accept;
|
||||
accept
|
||||
} else if (event.text == Keys.DownArrow && current-item + 1 < model.length) {
|
||||
actual-current-item += 1;
|
||||
return accept;
|
||||
accept
|
||||
} else {
|
||||
reject
|
||||
}
|
||||
reject
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue