Menu: Add enabled property (#8145)

By default it's enabled, of course. This property is not only added to
MenuItem, but Menu as well - since they can be nested. It's also
possible to select a disabled item, but it's hard to modify that since
it's logic is written in Slint. You should be prevented from activating
it with a tap or key press at least.

See #7791
This commit is contained in:
Joshua Goins 2025-04-15 02:08:11 -04:00 committed by GitHub
parent 44a1bec608
commit d1f2fef430
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 64 additions and 9 deletions

View file

@ -85,12 +85,12 @@ export component PopupMenuImpl inherits Window {
}
return accept;
} else if event.text == Key.Return {
if current-highlight >= 0 && current-highlight < entries.length {
if current-highlight >= 0 && current-highlight < entries.length && entries[current-highlight].enabled {
activate(entries[current-highlight], y-pos(current-highlight), current-highlight);
}
return accept;
} else if event.text == Key.RightArrow {
if current-highlight >= 0 && current-highlight < entries.length && entries[current-highlight].has-sub-menu {
if current-highlight >= 0 && current-highlight < entries.length && entries[current-highlight].has-sub-menu && entries[current-highlight].enabled {
activate(entries[current-highlight], y-pos(current-highlight), current-highlight);
}
return accept;