Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/Filee.App/Views/Pages/ToolbarPage.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ public ToolbarPage()
// drag goes on.
Root.AddHandler(PointerCaptureLostEvent, OnRootCaptureLost, RoutingStrategies.Direct, handledEventsToo: true);
AddHandler(GotFocusEvent, (_, e) => _lastFocused = e.Source as Control, RoutingStrategies.Bubble, handledEventsToo: true);
// The last input decides whether a focus the page gives (KeepFocus) draws the focus ring: a key press, yes; a
// click, no. Taken from the input itself, not from the last focus change, which doesn't happen at all when the
// clicked control already has the keyboard.
AddHandler(KeyDownEvent, (_, _) => _focusByKeyboard = true, RoutingStrategies.Tunnel, handledEventsToo: true);
AddHandler(PointerPressedEvent, (_, _) => _focusByKeyboard = false, RoutingStrategies.Tunnel, handledEventsToo: true);
// Before the list box, which doesn't move between the rows of its wrap panel.
PaletteTabs.AddHandler(KeyDownEvent, OnTabsKeyDown, RoutingStrategies.Tunnel);

Expand Down Expand Up @@ -170,12 +175,17 @@ private void KeepFocus()
|| !hidden.GetVisualAncestors().Contains(this))
return;
Control next = vm.IsAdjustingLook ? LookDone : vm.IsEditingGroup ? GroupBack : EditSize;
next.Focus(NavigationMethod.Tab);
// The focus ring is for the keyboard: after a click on Edit Donut Size or Done, the button that takes over keeps
// the keyboard but doesn't draw the ring (Tab would draw it, as if the user had tabbed there).
next.Focus(_focusByKeyboard ? NavigationMethod.Tab : NavigationMethod.Pointer);
}

// The control of this page that last had the keyboard (see KeepFocus).
private Control? _lastFocused;

/// <summary>The last input was a key press, not a click.</summary>
private bool _focusByKeyboard;

/// <summary>
/// The donut on screen while it's wanted: refilled when what is on it changed (<paramref name="reload"/>, and only
/// then: a search typed in the palette rebuilds the editor but changes nothing on it), else restyled; put away
Expand Down
Loading