Skip to content

armgit / nota

Public Imported from GitHub
0

Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.

(fix) Search focus fix

Egor Khindikaynena64586322995
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 17f32c4a..c3988dc6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -49,6 +49,11 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
Record and the rest as Win+S, Win+Z…, and Ctrl+S, Ctrl+Z and most of the others did
nothing. They now read and work as Ctrl+S, Ctrl+Z, Ctrl+Shift+Z and so on, and Settings ▸ Shortcuts, the Session inspector
and the other on-screen hints spell keys as Ctrl / Alt / Shift instead of ⌘ ⌥ ⇧.
+- **The browser search lets go of the keyboard:** once you had typed into it, clicking the
+ Arrangement, the piano roll or the Session grid left the cursor in the field, so Space,
+ note keys and shortcuts kept typing into the search. Clicking anywhere outside a text
+ field now hands the keyboard back to the app, and Esc in the search leaves it too (the
+ query stays).
## [0.50.1] — 2026-10-07
diff --git a/src/managed/Nota.App/BrowserView.cs b/src/managed/Nota.App/BrowserView.cs
index 8398095a..70c1822a 100644
--- a/src/managed/Nota.App/BrowserView.cs
+++ b/src/managed/Nota.App/BrowserView.cs
@@ -308,6 +308,13 @@ public sealed class BrowserView : UserControl
_search.TextChanged += (_, _) => { ApplyFilter(_active); };
_search.GotFocus += (_, _) => _searchWrap!.BindResource(Border.BorderBrushProperty, "Brush.Accent");
_search.LostFocus += (_, _) => _searchWrap!.BindResource(Border.BorderBrushProperty, "Brush.BorderDefault");
+ // Esc leaves the search (the query stays) so the keyboard goes back to the app.
+ _search.KeyDown += (_, e) =>
+ {
+ if (e.Key != Key.Escape) return;
+ TopLevel.GetTopLevel(_search)?.FocusManager?.Focus(null);
+ e.Handled = true;
+ };
_matchCount = new TextBlock
{
FontSize = 9,
diff --git a/src/managed/Nota.App/DetailWindow.cs b/src/managed/Nota.App/DetailWindow.cs
index 0b755ce0..267022f6 100644
--- a/src/managed/Nota.App/DetailWindow.cs
+++ b/src/managed/Nota.App/DetailWindow.cs
@@ -29,6 +29,7 @@ internal sealed class DetailWindow : NotaWindow
public DetailWindow(MainWindow owner)
{
_owner = owner;
+ MainWindow.ReleaseTextFocusOnOutsidePress(this);
// Route transport keys (Space/Return) in the tunnel phase so a focused control here
// can't steal them, exactly like the main window does.
diff --git a/src/managed/Nota.App/DeviceWindow.cs b/src/managed/Nota.App/DeviceWindow.cs
index f66f30e0..e2b31cb3 100644
--- a/src/managed/Nota.App/DeviceWindow.cs
+++ b/src/managed/Nota.App/DeviceWindow.cs
@@ -109,6 +109,7 @@ internal sealed class DeviceWindow : NotaWindow
AddHandler(KeyDownEvent, (_, e) => mw.HandleTransportKeyTunnel(e), RoutingStrategies.Tunnel);
KeyDown += (_, e) => { if (!e.Handled) mw.HandleFloatingKeyDown(e); };
KeyUp += (_, e) => { if (!e.Handled) mw.HandleKeyUp(e); };
+ MainWindow.ReleaseTextFocusOnOutsidePress(this);
}
Show(owner);
}
diff --git a/src/managed/Nota.App/MainWindow.Input.cs b/src/managed/Nota.App/MainWindow.Input.cs
index ce47aba2..0ab9dcc5 100644
--- a/src/managed/Nota.App/MainWindow.Input.cs
+++ b/src/managed/Nota.App/MainWindow.Input.cs
@@ -3,7 +3,9 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Threading.Tasks;
+using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
@@ -12,6 +14,7 @@ using Avalonia.Interactivity;
using Avalonia.Layout;
using Avalonia.Media;
using Avalonia.Platform.Storage;
+using Avalonia.VisualTree;
using Microsoft.Extensions.DependencyInjection;
using Nota.Application;
using Nota.Presentation;
@@ -68,6 +71,25 @@ public partial class MainWindow
}
}
+ // A text field keeps the keyboard until focus moves elsewhere — but the arrangement, piano
+ // roll, session grid etc. are custom-drawn and don't take focus on click, so after typing
+ // into e.g. the browser search every key kept going to the field. Any press outside the
+ // focused text field (or its NumericUpDown, spinners included) now drops its focus; a press
+ // on another focusable control still focuses that control as usual. Tunnel +
+ // handledEventsToo so canvases that consume the press can't keep it from running.
+ internal static void ReleaseTextFocusOnOutsidePress(TopLevel top)
+ {
+ top.AddHandler(PointerPressedEvent, (_, e) =>
+ {
+ if (top.FocusManager?.GetFocusedElement() is not Visual focused) return;
+ Visual? field = focused.FindAncestorOfType<TextBox>(includeSelf: true);
+ if (field is null) return;
+ field = field.FindAncestorOfType<NumericUpDown>() ?? field;
+ if (e.Source is Visual src && src.GetSelfAndVisualAncestors().Contains(field)) return;
+ top.FocusManager.Focus(null);
+ }, RoutingStrategies.Tunnel, handledEventsToo: true);
+ }
+
// The Session grid has the keyboard: its arrows / Return / ⌘C… act on its selection.
private bool SessionFocused => _session is { IsVisible: true, IsKeyboardFocusWithin: true };
diff --git a/src/managed/Nota.App/MainWindow.axaml.cs b/src/managed/Nota.App/MainWindow.axaml.cs
index f50055a0..3dad01fe 100644
--- a/src/managed/Nota.App/MainWindow.axaml.cs
+++ b/src/managed/Nota.App/MainWindow.axaml.cs
@@ -410,6 +410,9 @@ public partial class MainWindow : Window
// exempted inside the handler so typing still works). See OnGlobalTransportKey.
AddHandler(KeyDownEvent, OnGlobalTransportKey, RoutingStrategies.Tunnel);
+ // Clicking away from a text field (browser search, rename boxes…) hands the keyboard back.
+ ReleaseTextFocusOnOutsidePress(this);
+
Closed += (_, _) => vm.Dispose();
// MCP server: MCP tool edits redraw the arrangement + device panel; start the server if