Mouse.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. {
  11. Label ml;
  12. int count = 0;
  13. ml = new Label (new Rect (1, 1, 50, 1), "Mouse: ");
  14. List<string> rme = new List<string> ();
  15. var test = new Label (1, 2, "Se iniciará el análisis");
  16. Win.Add (test);
  17. Win.Add (ml);
  18. var rmeList = new ListView (rme) {
  19. X = Pos.Right (test) + 25,
  20. Y = Pos.Top (test) + 1,
  21. Width = Dim.Fill () - 1,
  22. Height = Dim.Fill (),
  23. ColorScheme = Colors.TopLevel
  24. };
  25. Win.Add (rmeList);
  26. Application.RootMouseEvent += delegate (MouseEvent me) {
  27. ml.Text = $"Mouse: ({me.X},{me.Y}) - {me.Flags} {count}";
  28. rme.Add ($"({me.X},{me.Y}) - {me.Flags} {count++}");
  29. rmeList.MoveDown ();
  30. };
  31. // I have no idea what this was intended to show off in demo.c
  32. var drag = new Label ("Drag: ") { X = 1, Y = 4 };
  33. var dragText = new TextField ("") {
  34. X = Pos.Right (drag),
  35. Y = Pos.Top (drag),
  36. Width = 40
  37. };
  38. Win.Add (drag, dragText);
  39. }
  40. }
  41. }