Global back listener for mouse.
This commit is contained in:
@@ -221,24 +221,29 @@ public class NavigationService : NavigationServiceBase, INavigationService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_statePersistanceService.ApplicationMode == WinoApplicationMode.Calendar)
|
var innerShellFrame = GetCoreFrame(NavigationReferenceFrame.InnerShellFrame);
|
||||||
{
|
|
||||||
var innerShellFrame = GetCoreFrame(NavigationReferenceFrame.InnerShellFrame);
|
|
||||||
if (innerShellFrame?.CanGoBack == true)
|
|
||||||
{
|
|
||||||
innerShellFrame.GoBack();
|
|
||||||
|
|
||||||
// Calendar mode: Navigate back from EventDetailsPage
|
if (_statePersistanceService.ApplicationMode == WinoApplicationMode.Calendar && innerShellFrame?.CanGoBack == true)
|
||||||
_statePersistanceService.IsEventDetailsVisible = false;
|
{
|
||||||
}
|
innerShellFrame.GoBack();
|
||||||
|
|
||||||
|
// Calendar mode: Navigate back from EventDetailsPage
|
||||||
|
_statePersistanceService.IsEventDetailsVisible = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Mail mode: Clear selections and dispose rendering frame
|
if (_statePersistanceService.IsReadingMail && _statePersistanceService.IsReaderNarrowed)
|
||||||
_statePersistanceService.IsReadingMail = false;
|
{
|
||||||
|
// Mail mode: Clear selections and dispose rendering frame
|
||||||
|
_statePersistanceService.IsReadingMail = false;
|
||||||
|
|
||||||
WeakReferenceMessenger.Default.Send(new ClearMailSelectionsRequested());
|
WeakReferenceMessenger.Default.Send(new ClearMailSelectionsRequested());
|
||||||
WeakReferenceMessenger.Default.Send(new DisposeRenderingFrameRequested());
|
WeakReferenceMessenger.Default.Send(new DisposeRenderingFrameRequested());
|
||||||
|
}
|
||||||
|
else if (innerShellFrame != null && innerShellFrame.CanGoBack)
|
||||||
|
{
|
||||||
|
innerShellFrame.GoBack();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow, IRecipient
|
|||||||
// Use the AppWindow.Closing event to handle the close request
|
// Use the AppWindow.Closing event to handle the close request
|
||||||
AppWindow.Closing += OnAppWindowClosing;
|
AppWindow.Closing += OnAppWindowClosing;
|
||||||
|
|
||||||
|
// Register global mouse button listener for back button
|
||||||
|
RegisterMouseBackButtonListener();
|
||||||
|
|
||||||
ShowWinoCommand = new RelayCommand(RestoreFromTray);
|
ShowWinoCommand = new RelayCommand(RestoreFromTray);
|
||||||
ExitWinoCommand = new RelayCommand(ForceClose);
|
ExitWinoCommand = new RelayCommand(ForceClose);
|
||||||
|
|
||||||
@@ -66,6 +69,30 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow, IRecipient
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RegisterMouseBackButtonListener()
|
||||||
|
{
|
||||||
|
// Subscribe to pointer pressed events on the root content
|
||||||
|
if (Content is UIElement rootElement)
|
||||||
|
{
|
||||||
|
rootElement.AddHandler(UIElement.PointerPressedEvent, new Microsoft.UI.Xaml.Input.PointerEventHandler(OnPointerPressed), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPointerPressed(object sender, Microsoft.UI.Xaml.Input.PointerRoutedEventArgs e)
|
||||||
|
{
|
||||||
|
// Check if it's the back button (XButton1)
|
||||||
|
var pointerPoint = e.GetCurrentPoint(null);
|
||||||
|
var properties = pointerPoint.Properties;
|
||||||
|
|
||||||
|
// XButton1 is the back button on most mice
|
||||||
|
if (properties.IsXButton1Pressed)
|
||||||
|
{
|
||||||
|
// Call GoBack on NavigationService
|
||||||
|
NavigationService.GoBack();
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void HandleAppActivation(LaunchActivatedEventArgs args)
|
public void HandleAppActivation(LaunchActivatedEventArgs args)
|
||||||
{
|
{
|
||||||
// Parse launch arguments to determine the application mode
|
// Parse launch arguments to determine the application mode
|
||||||
|
|||||||
Reference in New Issue
Block a user