diff --git a/MainPage.xaml.cs b/MainPage.xaml.cs index 0f1d4e3..a2c745a 100644 --- a/MainPage.xaml.cs +++ b/MainPage.xaml.cs @@ -21,6 +21,7 @@ public partial class MainPage : ContentPage, INotifyPropertyChanged // Для отслеживания двойного клика private DateTime _lastClickTime = DateTime.MinValue; private object _lastClickedButton = null; + private bool _awaitingConfirmation = false; public string LeftPath { @@ -104,6 +105,12 @@ public partial class MainPage : ContentPage, INotifyPropertyChanged MainThread.BeginInvokeOnMainThread(() => { + // Сбрасываем флаг для всех клавиш навигации + if (e.Key == "w" || e.Key == "s" || e.Key == "a" || e.Key == "d") + { + _awaitingConfirmation = true; + } + switch (e.Key) { case "w": // W - вверх @@ -351,6 +358,8 @@ public partial class MainPage : ContentPage, INotifyPropertyChanged System.Diagnostics.Debug.WriteLine($"Loaded {items.Count} items to {(isLeft ? "LEFT" : "RIGHT")} panel"); UpdateVisualState(); + _awaitingConfirmation = false; + // Устанавливаем фокус на первый элемент if (items.Count > 0) { @@ -403,30 +412,33 @@ public partial class MainPage : ContentPage, INotifyPropertyChanged private void HandleItemClick(Button button, FileSystemItem item, bool isLeft) { var currentTime = DateTime.Now; - var isDoubleClick = (currentTime - _lastClickTime).TotalMilliseconds < 500 + var isDoubleClick = (currentTime - _lastClickTime).TotalMilliseconds < 500 && _lastClickedButton == button; _lastClickTime = currentTime; _lastClickedButton = button; - System.Diagnostics.Debug.WriteLine($"=== CLICK: {item.Name} in {(isLeft ? "LEFT" : "RIGHT")} panel, Double: {isDoubleClick} ==="); + System.Diagnostics.Debug.WriteLine($"=== CLICK: {item.Name} in {(isLeft ? "LEFT" : "RIGHT")} panel, Double: {isDoubleClick}, AwaitingConfirm: {_awaitingConfirmation} ==="); // ВСЕГДА выделяем элемент при клике var panel = isLeft ? LeftPanel : RightPanel; var index = panel.Children.IndexOf(button); - + if (index >= 0) { _panelManager.SetSelection(index, isLeft); - - // Устанавливаем фокус на кнопку button.Focus(); ScrollToSelectedItem(); } - // Если это двойной клик - открываем/запускаем - if (isDoubleClick) + // Открываем, если: + // - двойной клик (мышь), ИЛИ + // - одиночный клик, но мы только что навигировались клавишами (Enter/Space имитация) + if (isDoubleClick || _awaitingConfirmation) { + // Сбрасываем флаг ПЕРЕД открытием + _awaitingConfirmation = false; + if (item.IsDirectory) { LoadDirectory(item.FullName, isLeft);