diff --git a/Dalamud/Game/Gui/Dtr/DtrBar.cs b/Dalamud/Game/Gui/Dtr/DtrBar.cs
index dac34f38d..bd8d8e1d7 100644
--- a/Dalamud/Game/Gui/Dtr/DtrBar.cs
+++ b/Dalamud/Game/Gui/Dtr/DtrBar.cs
@@ -641,7 +641,7 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar
break;
case AddonEventType.MouseClick:
- dtrBarEntry.OnClick?.Invoke(new AddonMouseEventData(eventData));
+ dtrBarEntry.OnClick?.Invoke(DtrInteractionEvent.FromMouseEvent(new AddonMouseEventData(eventData)));
break;
}
}
diff --git a/Dalamud/Game/Gui/Dtr/DtrBarEntry.cs b/Dalamud/Game/Gui/Dtr/DtrBarEntry.cs
index 54847705d..6fdc504ca 100644
--- a/Dalamud/Game/Gui/Dtr/DtrBarEntry.cs
+++ b/Dalamud/Game/Gui/Dtr/DtrBarEntry.cs
@@ -43,6 +43,11 @@ public interface IReadOnlyDtrBarEntry
/// Gets a value indicating whether the user has hidden this entry from view through the Dalamud settings.
///
public bool UserHidden { get; }
+
+ ///
+ /// Gets an action to be invoked when the user clicks on the dtr entry.
+ ///
+ public Action? OnClick { get; }
}
///
@@ -68,7 +73,7 @@ public interface IDtrBarEntry : IReadOnlyDtrBarEntry
///
/// Gets or sets an action to be invoked when the user clicks on the dtr entry.
///
- public Action? OnClick { get; set; }
+ public new Action? OnClick { get; set; }
///
/// Remove this entry from the bar.
@@ -118,7 +123,7 @@ internal sealed unsafe class DtrBarEntry : IDisposable, IDtrBarEntry
public SeString? Tooltip { get; set; }
///
- public Action? OnClick { get; set; }
+ public Action? OnClick { get; set; }
///
public bool HasClickAction => this.OnClick != null;
diff --git a/Dalamud/Game/Gui/Dtr/DtrInteractionEvent.cs b/Dalamud/Game/Gui/Dtr/DtrInteractionEvent.cs
new file mode 100644
index 000000000..8b2bd8a7d
--- /dev/null
+++ b/Dalamud/Game/Gui/Dtr/DtrInteractionEvent.cs
@@ -0,0 +1,59 @@
+using System.Numerics;
+
+using Dalamud.Game.Addon.Events.EventDataTypes;
+
+namespace Dalamud.Game.Gui.Dtr;
+
+///
+/// Represents an interaction event from the DTR system.
+///
+public class DtrInteractionEvent
+{
+ ///
+ /// Gets the type of mouse click (left or right).
+ ///
+ public MouseClickType ClickType { get; init; }
+
+ ///
+ /// Gets the modifier keys that were held during the click.
+ ///
+ public ClickModifierKeys ModifierKeys { get; init; }
+
+ ///
+ /// Gets the scroll direction of the mouse wheel, if applicable.
+ ///
+ public MouseScrollDirection ScrollDirection { get; init; }
+
+ ///
+ /// Gets lower-level mouse data, if this event came from native UI.
+ ///
+ /// Can only be set by Dalamud. If null, this event was manually created.
+ ///
+ public AddonMouseEventData? AtkEventSource { get; private init; }
+
+ ///
+ /// Gets the position of the mouse cursor when the event occurred.
+ ///
+ public Vector2 Position { get; init; }
+
+ ///
+ /// Helper to create a from an .
+ ///
+ /// The event.
+ /// A better event.
+ public static DtrInteractionEvent FromMouseEvent(AddonMouseEventData ev)
+ {
+ return new DtrInteractionEvent
+ {
+ AtkEventSource = ev,
+ ClickType = ev.IsLeftClick ? MouseClickType.Left : MouseClickType.Right,
+ ModifierKeys = (ev.IsAltHeld ? ClickModifierKeys.Alt : 0) |
+ (ev.IsControlHeld ? ClickModifierKeys.Ctrl : 0) |
+ (ev.IsShiftHeld ? ClickModifierKeys.Shift : 0),
+ ScrollDirection = ev.IsScrollUp ? MouseScrollDirection.Up :
+ ev.IsScrollDown ? MouseScrollDirection.Down :
+ MouseScrollDirection.None,
+ Position = ev.Position,
+ };
+ }
+}
diff --git a/Dalamud/Game/Gui/Dtr/DtrInteractionTypes.cs b/Dalamud/Game/Gui/Dtr/DtrInteractionTypes.cs
new file mode 100644
index 000000000..7c498dc94
--- /dev/null
+++ b/Dalamud/Game/Gui/Dtr/DtrInteractionTypes.cs
@@ -0,0 +1,65 @@
+namespace Dalamud.Game.Gui.Dtr;
+
+///
+/// An enum representing the mouse click types.
+///
+public enum MouseClickType
+{
+ ///
+ /// A left click.
+ ///
+ Left,
+
+ ///
+ /// A right click.
+ ///
+ Right,
+}
+
+///
+/// Modifier keys that can be held during a mouse click event.
+///
+[Flags]
+public enum ClickModifierKeys
+{
+ ///
+ /// No modifiers were present.
+ ///
+ None = 0,
+
+ ///
+ /// The CTRL key was held.
+ ///
+ Ctrl = 1 << 0,
+
+ ///
+ /// The ALT key was held.
+ ///
+ Alt = 1 << 1,
+
+ ///
+ /// The SHIFT key was held.
+ ///
+ Shift = 1 << 2,
+}
+
+///
+/// Possible directions for scroll wheel events.
+///
+public enum MouseScrollDirection
+{
+ ///
+ /// No scrolling.
+ ///
+ None = 0,
+
+ ///
+ /// A scroll up event.
+ ///
+ Up = 1,
+
+ ///
+ /// A scroll down event.
+ ///
+ Down = -1,
+}