MouseBinding.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #nullable enable
  2. namespace Terminal.Gui.Input;
  3. /// <summary>
  4. /// Provides a collection of <see cref="MouseFlags"/> bound to <see cref="Command"/>s.
  5. /// </summary>
  6. /// <seealso cref="MouseBindings"/>
  7. /// <seealso cref="Command"/>
  8. public record struct MouseBinding : IInputBinding
  9. {
  10. /// <summary>Initializes a new instance.</summary>
  11. /// <param name="commands">The commands this mouse binding will invoke.</param>
  12. /// <param name="mouseFlags">The mouse flags that triggered this binding.</param>
  13. public MouseBinding (Command [] commands, MouseFlags mouseFlags)
  14. {
  15. Commands = commands;
  16. MouseEventArgs = new MouseEventArgs()
  17. {
  18. Flags = mouseFlags
  19. };
  20. }
  21. /// <summary>Initializes a new instance.</summary>
  22. /// <param name="commands">The commands this mouse binding will invoke.</param>
  23. /// <param name="args">The mouse event that triggered this binding.</param>
  24. public MouseBinding (Command [] commands, MouseEventArgs args)
  25. {
  26. Commands = commands;
  27. MouseEventArgs = args;
  28. }
  29. /// <summary>The commands this binding will invoke.</summary>
  30. public Command [] Commands { get; set; }
  31. /// <inheritdoc />
  32. public object? Data { get; set; }
  33. /// <summary>
  34. /// The mouse event arguments.
  35. /// </summary>
  36. public MouseEventArgs? MouseEventArgs { get; set; }
  37. }