mirror of
https://gitee.com/chinware/atomui.git
synced 2024-11-29 18:38:16 +08:00
Fix NavMenu Interaction Handler bug
This commit is contained in:
parent
74bd9e4aa2
commit
c8caabbde8
@ -16,6 +16,7 @@ internal class DefaultNavMenuInteractionHandler : INavMenuInteractionHandler
|
|||||||
private IDisposable? _inputManagerSubscription;
|
private IDisposable? _inputManagerSubscription;
|
||||||
private IRenderRoot? _root;
|
private IRenderRoot? _root;
|
||||||
private IDisposable? _currentDelayRunDisposable;
|
private IDisposable? _currentDelayRunDisposable;
|
||||||
|
private bool _currentPressedIsValid = false;
|
||||||
|
|
||||||
public DefaultNavMenuInteractionHandler()
|
public DefaultNavMenuInteractionHandler()
|
||||||
: this(AvaloniaLocator.Current.GetService<IInputManager>(), DefaultDelayRun)
|
: this(AvaloniaLocator.Current.GetService<IInputManager>(), DefaultDelayRun)
|
||||||
@ -154,6 +155,8 @@ internal class DefaultNavMenuInteractionHandler : INavMenuInteractionHandler
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_currentPressedIsValid = true;
|
||||||
if (sender is Visual visual &&
|
if (sender is Visual visual &&
|
||||||
e.GetCurrentPoint(visual).Properties.IsLeftButtonPressed)
|
e.GetCurrentPoint(visual).Properties.IsLeftButtonPressed)
|
||||||
{
|
{
|
||||||
@ -192,22 +195,16 @@ internal class DefaultNavMenuInteractionHandler : INavMenuInteractionHandler
|
|||||||
protected virtual void PointerReleased(object? sender, PointerReleasedEventArgs e)
|
protected virtual void PointerReleased(object? sender, PointerReleasedEventArgs e)
|
||||||
{
|
{
|
||||||
var item = GetMenuItemCore(e.Source as Control);
|
var item = GetMenuItemCore(e.Source as Control);
|
||||||
if (item is null)
|
if (item is null || !_currentPressedIsValid)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item is NavMenuItem navMenuItem)
|
_currentPressedIsValid = false;
|
||||||
|
if (e.InitialPressMouseButton == MouseButton.Left && item?.HasSubMenu == false)
|
||||||
{
|
{
|
||||||
if (!navMenuItem.PointInNavMenuItemHeader(e.GetCurrentPoint(navMenuItem).Position))
|
Click(item);
|
||||||
{
|
e.Handled = true;
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (e.InitialPressMouseButton == MouseButton.Left && item?.HasSubMenu == false)
|
|
||||||
{
|
|
||||||
Click(item);
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@ internal class InlineNavMenuInteractionHandler : INavMenuInteractionHandler
|
|||||||
public void Attach(NavMenuBase navMenu) => AttachCore(navMenu);
|
public void Attach(NavMenuBase navMenu) => AttachCore(navMenu);
|
||||||
public void Detach(NavMenuBase navMenu) => DetachCore(navMenu);
|
public void Detach(NavMenuBase navMenu) => DetachCore(navMenu);
|
||||||
|
|
||||||
|
private bool _currentPressedIsValid = false;
|
||||||
|
|
||||||
internal void AttachCore(INavMenu navMenu)
|
internal void AttachCore(INavMenu navMenu)
|
||||||
{
|
{
|
||||||
if (NavMenu != null)
|
if (NavMenu != null)
|
||||||
@ -40,6 +42,8 @@ internal class InlineNavMenuInteractionHandler : INavMenuInteractionHandler
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_currentPressedIsValid = true;
|
||||||
|
|
||||||
if (sender is Visual visual &&
|
if (sender is Visual visual &&
|
||||||
e.GetCurrentPoint(visual).Properties.IsLeftButtonPressed)
|
e.GetCurrentPoint(visual).Properties.IsLeftButtonPressed)
|
||||||
@ -71,11 +75,13 @@ internal class InlineNavMenuInteractionHandler : INavMenuInteractionHandler
|
|||||||
protected virtual void PointerReleased(object? sender, PointerReleasedEventArgs e)
|
protected virtual void PointerReleased(object? sender, PointerReleasedEventArgs e)
|
||||||
{
|
{
|
||||||
var item = GetMenuItemCore(e.Source as Control);
|
var item = GetMenuItemCore(e.Source as Control);
|
||||||
if (item is null || !item.PointInNavMenuItemHeader(e.GetCurrentPoint(item).Position))
|
if (item is null || !_currentPressedIsValid)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_currentPressedIsValid = false;
|
||||||
|
|
||||||
if (e.InitialPressMouseButton == MouseButton.Left && !item.HasSubMenu)
|
if (e.InitialPressMouseButton == MouseButton.Left && !item.HasSubMenu)
|
||||||
{
|
{
|
||||||
Click(item);
|
Click(item);
|
||||||
|
Loading…
Reference in New Issue
Block a user