From a1fc14175315987db3335783514ae8224d0c47e4 Mon Sep 17 00:00:00 2001 From: JoeZiminski Date: Wed, 17 Dec 2025 16:05:48 +0000 Subject: [PATCH 1/2] Fix focus issue. --- datashuttle/tui/custom_widgets.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/datashuttle/tui/custom_widgets.py b/datashuttle/tui/custom_widgets.py index 5ab548fca..4597bd75a 100644 --- a/datashuttle/tui/custom_widgets.py +++ b/datashuttle/tui/custom_widgets.py @@ -12,6 +12,7 @@ from collections.abc import Iterable from textual import events + from textual.events import MouseMove from textual.validation import Validator from datashuttle.tui.app import TuiApp @@ -146,6 +147,16 @@ def __init__( self.mainwindow = mainwindow + def on_mouse_move(self, event: MouseMove) -> None: + """Handle focus for this widget. + + Explicitly grab focus when mouse moves into widget so that + keyboard shortcuts work without having to click the folder. + """ + if not self.has_focus: # type: ignore + self.focus() + self.has_focus = True + def filter_paths(self, paths: Iterable[Path]) -> Iterable[Path]: """Filter out all hidden folders and files from CustomDirectoryTree display. From 262b94e9b39ae36624ee32ab835cb24ee6d699ac Mon Sep 17 00:00:00 2001 From: JoeZiminski Date: Wed, 17 Dec 2025 16:28:14 +0000 Subject: [PATCH 2/2] Remove unecessary has_focus set. --- datashuttle/tui/custom_widgets.py | 1 - 1 file changed, 1 deletion(-) diff --git a/datashuttle/tui/custom_widgets.py b/datashuttle/tui/custom_widgets.py index 4597bd75a..afd0d90ec 100644 --- a/datashuttle/tui/custom_widgets.py +++ b/datashuttle/tui/custom_widgets.py @@ -155,7 +155,6 @@ def on_mouse_move(self, event: MouseMove) -> None: """ if not self.has_focus: # type: ignore self.focus() - self.has_focus = True def filter_paths(self, paths: Iterable[Path]) -> Iterable[Path]: """Filter out all hidden folders and files from CustomDirectoryTree display.