Fixes #355 stack overflow with Pos based on the size of windows at startup. Added a OnResized action to set the Pos after the terminal are resized. (#367)

This commit is contained in:
BDisp
2020-04-15 02:50:17 +01:00
committed by GitHub
parent 12cfbb8231
commit ee7fc3022d
2 changed files with 55 additions and 45 deletions

View File

@@ -88,7 +88,7 @@ static class Demo {
"Text Alignments", 50, 20,
new Button ("Ok", is_default: true) { Clicked = () => { Application.RequestStop (); } },
new Button ("Cancel") { Clicked = () => { Application.RequestStop (); } });
int i = 0;
string txt = "Hello world, how are you doing today";
@@ -418,6 +418,8 @@ static class Demo {
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo ("en-US");
//Application.UseSystemConsole = true;
Console.WindowHeight = 35;
Application.Init ();
var top = Application.Top;
@@ -521,14 +523,16 @@ static class Demo {
});
win.Add (drag, dragText);
#if false
#if true
// This currently causes a stack overflow, because it is referencing a window that has not had its size allocated yet
var bottom = new Label ("This should go on the bottom!") {
X = Pos.Left (win),
Y = Pos.Bottom (win)
};
var bottom = new Label ("This should go on the bottom!");
win.Add (bottom);
Application.OnResized = () => {
bottom.X = Pos.Left (win);
bottom.Y = Pos.Bottom (win);
};
#endif
top.Add (win);