Let Back close the presets menu instead of the application

The presets menu at the foot of the tool rail is a PopupWindow, and
showing a popup takes focus off the develop view until it closes. The
menu held nothing focusable, so Android's Back gesture, pressed to
dismiss it, found no focus item, went unanswered, and the platform
closed the application. Slint closes a popup on Escape by itself but
not on Back.

The menu now holds a key scope, as the film list does, that closes it
on Back or Escape. The next Back leaves develop for the grid.
This commit is contained in:
2026-09-30 22:11:51 -04:00
parent 6f33517b35
commit 36556729f1
3 changed files with 100 additions and 6 deletions
+25
View File
@@ -55,6 +55,7 @@ import { Icon } from "icons.slint";
import { ViewMode } from "session.slint";
import { PresetRow, PresetOrigin, PresetFolderRow } from "presets.slint";
import { Label, ScrollBar } from "widgets.slint";
import { Keys } from "keys.slint";
// One tool. A struct rather than four parallel arrays so a row cannot be
// half-added — the compiler will not let a new entry omit its icon.
@@ -522,6 +523,30 @@ export component ToolRail inherits Rectangle {
root.height - Theme.gap);
close-policy: PopupClosePolicy.close-on-click-outside;
// Somewhere for Back to start from while the menu is up.
//
// A popup is its own focus tree: showing it takes focus off the
// develop view, and Slint hands it back only when the popup
// closes. With nothing focusable in here, Android's Back gesture
// — the natural way to dismiss a menu — found no focus item,
// went unanswered, and the platform closed the application.
// Slint closes a popup on Escape by itself but knows nothing of
// Back, so both are answered here, as the film list does.
FocusScope {
width: 0px;
height: 0px;
init => { self.focus(); }
// KEYMAP: Develop
key-pressed(event) => {
if (Keys.chord(event) == "Escape" || Keys.chord(event) == "Back") {
preset-menu.close();
return accept;
}
return reject;
}
}
Rectangle {
background: Theme.surface;
border-radius: Theme.radius;