флаг для открытия директорий

main
Stepan Pilipenko 3 weeks ago
parent 4a352df139
commit 3cb874f99c

@ -21,6 +21,7 @@ public partial class MainPage : ContentPage, INotifyPropertyChanged
// Для отслеживания двойного клика // Для отслеживания двойного клика
private DateTime _lastClickTime = DateTime.MinValue; private DateTime _lastClickTime = DateTime.MinValue;
private object _lastClickedButton = null; private object _lastClickedButton = null;
private bool _awaitingConfirmation = false;
public string LeftPath public string LeftPath
{ {
@ -104,6 +105,12 @@ public partial class MainPage : ContentPage, INotifyPropertyChanged
MainThread.BeginInvokeOnMainThread(() => MainThread.BeginInvokeOnMainThread(() =>
{ {
// Сбрасываем флаг для всех клавиш навигации
if (e.Key == "w" || e.Key == "s" || e.Key == "a" || e.Key == "d")
{
_awaitingConfirmation = true;
}
switch (e.Key) switch (e.Key)
{ {
case "w": // W - вверх 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"); System.Diagnostics.Debug.WriteLine($"Loaded {items.Count} items to {(isLeft ? "LEFT" : "RIGHT")} panel");
UpdateVisualState(); UpdateVisualState();
_awaitingConfirmation = false;
// Устанавливаем фокус на первый элемент // Устанавливаем фокус на первый элемент
if (items.Count > 0) if (items.Count > 0)
{ {
@ -409,7 +418,7 @@ public partial class MainPage : ContentPage, INotifyPropertyChanged
_lastClickTime = currentTime; _lastClickTime = currentTime;
_lastClickedButton = button; _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 panel = isLeft ? LeftPanel : RightPanel;
@ -418,15 +427,18 @@ public partial class MainPage : ContentPage, INotifyPropertyChanged
if (index >= 0) if (index >= 0)
{ {
_panelManager.SetSelection(index, isLeft); _panelManager.SetSelection(index, isLeft);
// Устанавливаем фокус на кнопку
button.Focus(); button.Focus();
ScrollToSelectedItem(); ScrollToSelectedItem();
} }
// Если это двойной клик - открываем/запускаем // Открываем, если:
if (isDoubleClick) // - двойной клик (мышь), ИЛИ
// - одиночный клик, но мы только что навигировались клавишами (Enter/Space имитация)
if (isDoubleClick || _awaitingConfirmation)
{ {
// Сбрасываем флаг ПЕРЕД открытием
_awaitingConfirmation = false;
if (item.IsDirectory) if (item.IsDirectory)
{ {
LoadDirectory(item.FullName, isLeft); LoadDirectory(item.FullName, isLeft);

Loading…
Cancel
Save