Files
Terminal.Gui/UICatalog/Scenarios/Mouse.cs
Tig 6851b42a49 Fixes #2921 - MainLoop refactoring (#2922)
* Adds basic MainLoop unit tests

* Remove WinChange action from Curses

* Remove WinChange action from Curses

* Remove ProcessInput action from Windows MainLoop

* Simplified MainLoop/ConsoleDriver by making MainLoop internal and moving impt fns to Application

* Modernized Terminal resize events

* Modernized Terminal resize events

* Removed un used property

* for _isWindowsTerminal devenv->wininit; not sure what changed

* Modernized mouse/keyboard events (Action->EventHandler)

* Updated OnMouseEvent API docs

* Using WT_SESSION to detect WT

* removes hacky GetParentProcess

* Updates to fix #2634 (clear last line)

* removes hacky GetParentProcess2

* Addressed mac resize issue

* Addressed mac resize issue

* Removes ConsoleDriver.PrepareToRun, has Init return MainLoop

* Removes unneeded Attribute methods

* Removed GetProcesssName

* Removed GetProcesssName

* Refactored KeyEvent and KeyEventEventArgs into a single class

* Revert "Refactored KeyEvent and KeyEventEventArgs into a single class"

This reverts commit 88a00658db.

* Fixed key repeat issue; reverted stupidity on 1049/1047 confusion

* Updated CSI API Docs

* merge
2023-10-21 08:06:04 -07:00

47 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using Terminal.Gui;
namespace UICatalog.Scenarios {
[ScenarioMetadata (Name: "Mouse", Description: "Demonstrates how to capture mouse events")]
[ScenarioCategory ("Mouse and Keyboard")]
public class Mouse : Scenario {
public override void Setup ()
{
Label ml;
int count = 0;
ml = new Label (new Rect (1, 1, 50, 1), "Mouse: ");
List<string> rme = new List<string> ();
var test = new Label (1, 2, "Se iniciará el análisis");
Win.Add (test);
Win.Add (ml);
var rmeList = new ListView (rme) {
X = Pos.Right (test) + 25,
Y = Pos.Top (test) + 1,
Width = Dim.Fill () - 1,
Height = Dim.Fill (),
ColorScheme = Colors.TopLevel
};
Win.Add (rmeList);
Application.MouseEvent += (sender, a) => {
ml.Text = $"Mouse: ({a.MouseEvent.X},{a.MouseEvent.Y}) - {a.MouseEvent.Flags} {count}";
rme.Add ($"({a.MouseEvent.X},{a.MouseEvent.Y}) - {a.MouseEvent.Flags} {count++}");
rmeList.MoveDown ();
};
// I have no idea what this was intended to show off in demo.c
var drag = new Label ("Drag: ") { X = 1, Y = 4 };
var dragText = new TextField ("") {
X = Pos.Right (drag),
Y = Pos.Top (drag),
Width = 40
};
Win.Add (drag, dragText);
}
}
}