using System.Text;
using Terminal.Gui;
namespace Test
{
public class Program
{
static readonly Label debugLabel = new ();
static void Main()
{
Application.Init();
var container = new View() { Id = "Container", X = Pos.Center(), Y = Pos.Center(), Width = 16, Height = 16 };
var top = new FrameView() { Id = "Top", Width = Dim.Fill(), Height = 12 };
var bottom = new FrameView() { Id = "Bottom", Y = Pos.Bottom(top), Width = Dim.Fill(), Height = 4 };
var label = new Label() {
Id = "Label",
X = Pos.Center(),
Y = Pos.Center(),
Text = "1\n2\n3\n4\n5\n6\n7\n8\n9\n10"
};
top.Add(label);
container.Add(top, bottom);
Application.Top.Add(container, debugLabel);
Application.RootMouseEvent += (me) => Top_Resized(null, top, bottom, label, me);
Application.Top.Resized += (obj) => Top_Resized(obj, top, bottom, label);
Application.Run();
return;
}
private static void Top_Resized(Size? obj, View top, View bottom, View label, MouseEvent? me = null)
{
top.GetCurrentWidth(out int topWidth);
top.GetCurrentHeight(out int topHeight);
bottom.GetCurrentWidth(out int bottomWidth);
bottom.GetCurrentHeight(out int bottomHeight);
label.GetCurrentWidth(out int labelWidth);
label.GetCurrentHeight(out int labelHeight);
var sb = new StringBuilder();
sb.AppendLine("Mouse");
sb.AppendLine("###############");
sb.AppendLine($"X: {me?.X}, Y: {me?.Y}");
sb.AppendLine($"Under cursor: {me?.View.Id}");
sb.AppendLine();
sb.AppendLine("Size");
sb.AppendLine("###############");
sb.AppendLine($"Top: [{topHeight}, {topHeight}]");
sb.AppendLine($"Bottom: [{bottomHeight}, {bottomHeight}]");
sb.AppendLine($"Label: [{labelHeight}, {labelHeight}]");
debugLabel.Text = sb.ToString();
}
}
}
Screenshots

Desktop:
To Reproduce