Mouse.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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.TextColor = Colors.TopLevel.Normal;
  28. ml.Text = $"Mouse: ({me.X},{me.Y}) - {me.Flags} {count}";
  29. rme.Add ($"({me.X},{me.Y}) - {me.Flags} {count++}");
  30. rmeList.MoveDown ();
  31. };
  32. // I have no idea what this was intended to show off in demo.c
  33. var drag = new Label ("Drag: ") { X = 1, Y = 4 };
  34. var dragText = new TextField ("") {
  35. X = Pos.Right (drag),
  36. Y = Pos.Top (drag),
  37. Width = 40
  38. };
  39. Win.Add (drag, dragText);
  40. }
  41. }
  42. }