MouseEventArgs.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132
  1. #nullable enable
  2. using System.ComponentModel;
  3. namespace Terminal.Gui;
  4. /// <summary>
  5. /// Specifies the event arguments for <see cref="Terminal.Gui.MouseEventArgs"/>. This is a higher-level construct than
  6. /// the wrapped <see cref="Terminal.Gui.MouseEventArgs"/> class and is used for the events defined on <see cref="View"/> and subclasses
  7. /// of View (e.g. <see cref="View.MouseEnter"/> and <see cref="View.MouseClick"/>).
  8. /// </summary>
  9. public class MouseEventArgs : HandledEventArgs
  10. {
  11. /// <summary>
  12. /// Flags indicating the state of the mouse buttons and the type of event that occurred.
  13. /// </summary>
  14. public MouseFlags Flags { get; set; }
  15. /// <summary>
  16. /// The screen-relative mouse position.
  17. /// </summary>
  18. public Point ScreenPosition { get; set; }
  19. /// <summary>The deepest View who's <see cref="View.Frame"/> contains <see cref="ScreenPosition"/>.</summary>
  20. public View? View { get; set; }
  21. /// <summary>The position of the mouse in <see cref="View"/>'s Viewport-relative coordinates. Only valid if <see cref="View"/> is set.</summary>
  22. public Point Position { get; set; }
  23. /// <summary>Returns a <see cref="T:System.String"/> that represents the current <see cref="Terminal.Gui.MouseEventArgs"/>.</summary>
  24. /// <returns>A <see cref="T:System.String"/> that represents the current <see cref="Terminal.Gui.MouseEventArgs"/>.</returns>
  25. public override string ToString () { return $"({ScreenPosition}):{Flags}:{View?.Id}:{Position}"; }
  26. }