Mouse.cs 922 B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Terminal.Gui;
  5. namespace UICatalog {
  6. [ScenarioMetadata (Name: "Mouse", Description: "Demonstrates how to capture mouse events")]
  7. [ScenarioCategory ("Input")]
  8. class Mouse : Scenario {
  9. public override void Setup () {
  10. Label ml;
  11. int count = 0;
  12. ml = new Label (new Rect (1, 1, 50, 1), "Mouse: ");
  13. Application.RootMouseEvent += delegate (MouseEvent me) {
  14. ml.TextColor = Colors.TopLevel.Normal;
  15. ml.Text = $"Mouse: ({me.X},{me.Y}) - {me.Flags} {count++}";
  16. };
  17. var test = new Label (1, 2, "Se iniciará el análisis");
  18. Win.Add (test);
  19. Win.Add (ml);
  20. // I have no idea what this was intended to show off in demo.c
  21. var drag = new Label ("Drag: ") { X = 1, Y = 4 };
  22. var dragText = new TextField ("") {
  23. X = Pos.Right (drag),
  24. Y = Pos.Top (drag),
  25. Width = 40
  26. };
  27. Win.Add (drag, dragText);
  28. }
  29. }
  30. }