using System;
namespace Terminal.Gui;
///
/// Mouse flags reported in .
///
///
/// They just happen to map to the ncurses ones.
///
[Flags]
public enum MouseFlags {
///
/// The first mouse button was pressed.
///
Button1Pressed = unchecked((int)0x2),
///
/// The first mouse button was released.
///
Button1Released = unchecked((int)0x1),
///
/// The first mouse button was clicked (press+release).
///
Button1Clicked = unchecked((int)0x4),
///
/// The first mouse button was double-clicked.
///
Button1DoubleClicked = unchecked((int)0x8),
///
/// The first mouse button was triple-clicked.
///
Button1TripleClicked = unchecked((int)0x10),
///
/// The second mouse button was pressed.
///
Button2Pressed = unchecked((int)0x80),
///
/// The second mouse button was released.
///
Button2Released = unchecked((int)0x40),
///
/// The second mouse button was clicked (press+release).
///
Button2Clicked = unchecked((int)0x100),
///
/// The second mouse button was double-clicked.
///
Button2DoubleClicked = unchecked((int)0x200),
///
/// The second mouse button was triple-clicked.
///
Button2TripleClicked = unchecked((int)0x400),
///
/// The third mouse button was pressed.
///
Button3Pressed = unchecked((int)0x2000),
///
/// The third mouse button was released.
///
Button3Released = unchecked((int)0x1000),
///
/// The third mouse button was clicked (press+release).
///
Button3Clicked = unchecked((int)0x4000),
///
/// The third mouse button was double-clicked.
///
Button3DoubleClicked = unchecked((int)0x8000),
///
/// The third mouse button was triple-clicked.
///
Button3TripleClicked = unchecked((int)0x10000),
///
/// The fourth mouse button was pressed.
///
Button4Pressed = unchecked((int)0x80000),
///
/// The fourth mouse button was released.
///
Button4Released = unchecked((int)0x40000),
///
/// The fourth button was clicked (press+release).
///
Button4Clicked = unchecked((int)0x100000),
///
/// The fourth button was double-clicked.
///
Button4DoubleClicked = unchecked((int)0x200000),
///
/// The fourth button was triple-clicked.
///
Button4TripleClicked = unchecked((int)0x400000),
///
/// Flag: the shift key was pressed when the mouse button took place.
///
ButtonShift = unchecked((int)0x2000000),
///
/// Flag: the ctrl key was pressed when the mouse button took place.
///
ButtonCtrl = unchecked((int)0x1000000),
///
/// Flag: the alt key was pressed when the mouse button took place.
///
ButtonAlt = unchecked((int)0x4000000),
///
/// The mouse position is being reported in this event.
///
ReportMousePosition = unchecked((int)0x8000000),
///
/// Vertical button wheeled up.
///
WheeledUp = unchecked((int)0x10000000),
///
/// Vertical button wheeled down.
///
WheeledDown = unchecked((int)0x20000000),
///
/// Vertical button wheeled up while pressing ButtonShift.
///
WheeledLeft = ButtonShift | WheeledUp,
///
/// Vertical button wheeled down while pressing ButtonShift.
///
WheeledRight = ButtonShift | WheeledDown,
///
/// Mask that captures all the events.
///
AllEvents = unchecked((int)0x7ffffff),
}
// TODO: Merge MouseEvent and MouseEventEventArgs into a single class.
///
/// Low-level construct that conveys the details of mouse events, such
/// as coordinates and button state, from ConsoleDrivers up to and
/// Views.
///
/// The class includes the
/// Action which takes a MouseEvent argument.
public class MouseEvent {
///
/// The X (column) location for the mouse event.
///
public int X { get; set; }
///
/// The Y (column) location for the mouse event.
///
public int Y { get; set; }
///
/// Flags indicating the kind of mouse event that is being posted.
///
public MouseFlags Flags { get; set; }
///
/// The offset X (column) location for the mouse event.
///
public int OfX { get; set; }
///
/// The offset Y (column) location for the mouse event.
///
public int OfY { get; set; }
///
/// The current view at the location for the mouse event.
///
public View View { get; set; }
///
/// Indicates if the current mouse event has already been processed and the driver should stop notifying any other event subscriber.
/// Its important to set this value to true specially when updating any View's layout from inside the subscriber method.
///
public bool Handled { get; set; }
///
/// Returns a that represents the current .
///
/// A that represents the current .
public override string ToString ()
{
return $"({X},{Y}):{Flags}";
}
}