Close menus with Escape and keep a window's popups focused
AppMenuAnchor is the app's one MenuAnchor: root overlay, takes the keyboard while open (Escape and arrows work wherever focus was) and gives it back. A window no longer takes the keyboard back from a popup its own press opened. In a window, Files opens as a page of that window and Chat details is in the More menu.
This commit is contained in:
@@ -117,9 +117,12 @@ class _WindowLayerState extends State<WindowLayer>
|
||||
);
|
||||
}
|
||||
|
||||
/// A press brings the window to the top and gives it the keyboard at
|
||||
/// once, before the press does anything else (focus a field, open a
|
||||
/// popup that takes the keyboard itself).
|
||||
void _pressed() {
|
||||
if (!widget.focus.has(_id)) widget.focus.focusNow(_id);
|
||||
widget.manager.raise(_id);
|
||||
if (!widget.focus.has(_id)) widget.focus.focusSoon(_id);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -203,6 +206,7 @@ class _WindowLayerState extends State<WindowLayer>
|
||||
],
|
||||
);
|
||||
final center = widget.bounds.center(Offset.zero);
|
||||
final current = ModalRoute.of(context)?.isCurrent ?? true;
|
||||
return AnimatedBuilder(
|
||||
animation: _reveal,
|
||||
builder: (context, child) {
|
||||
@@ -213,7 +217,9 @@ class _WindowLayerState extends State<WindowLayer>
|
||||
enabled: !offstage,
|
||||
child: SurfaceVisibility(
|
||||
shown: !offstage,
|
||||
current: !hiding,
|
||||
// Not while a page, sheet or dialog covers the app: the
|
||||
// window's own route is always its navigator's current one.
|
||||
current: !hiding && current,
|
||||
child: IgnorePointer(
|
||||
ignoring: hiding,
|
||||
child: ExcludeFocus(excluding: hiding, child: child!),
|
||||
|
||||
Reference in New Issue
Block a user