mirror of
https://github.com/lantean-code/qbtmud.git
synced 2025-10-23 04:52:22 +00:00
Fix longpress issue
This commit is contained in:
47
Lantean.QBTMud/Helpers/EventArgsExtensions.cs
Normal file
47
Lantean.QBTMud/Helpers/EventArgsExtensions.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using Lantean.QBTMud;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
|
||||
namespace Lantean.QBTMud.Helpers
|
||||
{
|
||||
public static class EventArgsExtensions
|
||||
{
|
||||
public static EventArgs NormalizeForContextMenu(this EventArgs eventArgs)
|
||||
{
|
||||
if (eventArgs is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(eventArgs));
|
||||
}
|
||||
|
||||
if (eventArgs is LongPressEventArgs longPressEventArgs)
|
||||
{
|
||||
return longPressEventArgs.ToMouseEventArgs();
|
||||
}
|
||||
|
||||
return eventArgs;
|
||||
}
|
||||
|
||||
public static MouseEventArgs ToMouseEventArgs(this LongPressEventArgs longPressEventArgs)
|
||||
{
|
||||
if (longPressEventArgs is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(longPressEventArgs));
|
||||
}
|
||||
|
||||
return new MouseEventArgs
|
||||
{
|
||||
Button = 2,
|
||||
Buttons = 2,
|
||||
ClientX = longPressEventArgs.ClientX,
|
||||
ClientY = longPressEventArgs.ClientY,
|
||||
OffsetX = longPressEventArgs.OffsetX,
|
||||
OffsetY = longPressEventArgs.OffsetY,
|
||||
PageX = longPressEventArgs.PageX,
|
||||
PageY = longPressEventArgs.PageY,
|
||||
ScreenX = longPressEventArgs.ScreenX,
|
||||
ScreenY = longPressEventArgs.ScreenY,
|
||||
Type = longPressEventArgs.Type ?? "contextmenu",
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user