Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toplevel or Window should allow set IsMdiContainer property. #226

Closed
BDisp opened this issue Aug 25, 2023 · 7 comments
Closed

Toplevel or Window should allow set IsMdiContainer property. #226

BDisp opened this issue Aug 25, 2023 · 7 comments

Comments

@BDisp
Copy link
Contributor

BDisp commented Aug 25, 2023

Case IsMdiContainer is true the user is responsible to create another Window class and call Application.Run<myChildClass> in the code.

@BDisp
Copy link
Contributor Author

BDisp commented Aug 29, 2023

Generated with the TerminalGuiDesigner but testing with the PR gui-cs/Terminal.Gui#2778.

using Terminal.Gui;
using YourNamespace;

public class Program {
	public void Main(string[] args)
	{
		Application.Run<MyView>();
		Application.Shutdown();
	}
}

//------------------------------------------------------------------------------

//  <auto-generated>
//      This code was generated by:
//        TerminalGuiDesigner v1.0.24.0
//      You can make changes to this file and they will not be overwritten when saving.
//  </auto-generated>
// -----------------------------------------------------------------------------
namespace YourNamespace {
	using Terminal.Gui;


	public partial class MyView {
		MyChildView _childView1;
		MyChildView _childView2;

		public MyView ()
		{
			InitializeComponent ();
			Title = "Parent";
			_childView1 = new () { Width = 20, Height = 10, Title = "Child1" };
			_childView2 = new () { X = Pos.Right (_childView1), Y = Pos.Bottom (_childView1), Width = 20, Height = 10, Title = "Child2" };
			Ready += () => Application.Run (_childView1);
			_childView1.Ready += () => Application.Run (_childView2);
		}
	}
}

//------------------------------------------------------------------------------

//  <auto-generated>
//      This code was generated by:
//        TerminalGuiDesigner v1.0.24.0
//      Changes to this file may cause incorrect behavior and will be lost if
//      the code is regenerated.
//  </auto-generated>
// -----------------------------------------------------------------------------
namespace YourNamespace {
	using System;
	using Terminal.Gui;


	public partial class MyView : Terminal.Gui.Window {

		private void InitializeComponent ()
		{
			this.Width = Dim.Fill (0);
			this.Height = Dim.Fill (0);
			this.X = 0;
			this.Y = 0;
			this.Modal = false;
			this.IsMdiContainer = true;
			this.Border.BorderStyle = Terminal.Gui.BorderStyle.Single;
			this.Border.Effect3D = false;
			this.Border.Effect3DBrush = null;
			this.Border.DrawMarginFrame = true;
			this.TextAlignment = Terminal.Gui.TextAlignment.Left;
			this.Title = "";
		}
	}
}

//------------------------------------------------------------------------------

//  <auto-generated>
//      This code was generated by:
//        TerminalGuiDesigner v1.0.24.0
//      You can make changes to this file and they will not be overwritten when saving.
//  </auto-generated>
// -----------------------------------------------------------------------------
namespace YourNamespace {
	using Terminal.Gui;


	public partial class MyChildView {

		public MyChildView ()
		{
			InitializeComponent ();
		}
	}
}

//------------------------------------------------------------------------------

//  <auto-generated>
//      This code was generated by:
//        TerminalGuiDesigner v1.0.24.0
//      Changes to this file may cause incorrect behavior and will be lost if
//      the code is regenerated.
//  </auto-generated>
// -----------------------------------------------------------------------------
namespace YourNamespace {
	using System;
	using Terminal.Gui;


	public partial class MyChildView : Terminal.Gui.Window {

		private Terminal.Gui.Label label;

		private Terminal.Gui.TextField textField;

		private void InitializeComponent ()
		{
			this.textField = new Terminal.Gui.TextField ();
			this.label = new Terminal.Gui.Label ();
			this.Width = Dim.Fill (0);
			this.Height = Dim.Fill (0);
			this.X = 0;
			this.Y = 0;
			this.Modal = false;
			this.IsMdiContainer = false;
			this.Border.BorderStyle = Terminal.Gui.BorderStyle.Single;
			this.Border.Effect3D = false;
			this.Border.Effect3DBrush = null;
			this.Border.DrawMarginFrame = true;
			this.TextAlignment = Terminal.Gui.TextAlignment.Left;
			this.Title = "";
			this.label.Width = 4;
			this.label.Height = 1;
			this.label.X = 0;
			this.label.Y = 0;
			this.label.Data = "label";
			this.label.Text = "Name:";
			this.label.TextAlignment = Terminal.Gui.TextAlignment.Left;
			this.Add (this.label);
			this.textField.Width = 10;
			this.textField.Height = 1;
			this.textField.X = 6;
			this.textField.Y = 0;
			this.textField.Secret = false;
			this.textField.Data = "textField";
			this.textField.Text = "";
			this.textField.TextAlignment = Terminal.Gui.TextAlignment.Left;
			this.Add (this.textField);
		}
	}
}
mdi-container.mp4

@tznind
Copy link
Collaborator

tznind commented Aug 30, 2023

Can you please create a PR that just contains 91a1a22

I have cherry-picked it but get null references when I set it to true and continue using editor.

For example:

  • Open a window
  • Add a FrameView
  • Delete the FrameView
  • Repeat after setting IsMdiContainer=true

bad-mdi

Global Exception
Object reference not set to an instance of an object.
   at Terminal.Gui.Toplevel.PositionCursor()
   at Terminal.Gui.View.PositionCursor()
   at Terminal.Gui.Toplevel.PositionCursor()
   at Terminal.Gui.Application.RunMainLoopIteration(RunState& state, Boolean
 wait, Boolean& firstIteration)
   at Terminal.Gui.Application.RunLoop(RunState state, Boolean wait)
   at Terminal.Gui.Application.Run(Toplevel view, Func`2 errorHandler)

@tznind
Copy link
Collaborator

tznind commented Aug 30, 2023

This crash isn't nessesarily a show stopper. It may be that the property is not designed to be changed during runtime of app. In this case I think we could add the concept of a 'MemoryOnlyProperty` (needs a better name).

In this case the Property would store the state (true/false) but not actually change the value on the View. This would be useful for the case of View.Visible too which it would be nice to edit but we really don't want to actually result in vanishing from the editor!

@tznind
Copy link
Collaborator

tznind commented Aug 30, 2023

I have added the concept of a SuppressedProperty which is useful for Visible but I think also could be handy for this use case too. See: #228

I've added you as a reviewer to get your impressions of the feature.

If accepted, I will need to port the PR to v2 branch also.

@BDisp
Copy link
Contributor Author

BDisp commented Aug 30, 2023

Can you please create a PR that just contains 91a1a22

I have cherry-picked it but get null references when I set it to true and continue using editor.

For example:

* Open a window

* Add a FrameView

* Delete the FrameView

* Repeat after setting IsMdiContainer=true

I tried before doing a separate PR to this but it only works with the #227. Can you test on that PR and check if the error persist, please?

Edit:
Forget, throws the same error. I'll investigate the cause. Thanks for related this. I'll create a PR to this issue.

@BDisp
Copy link
Contributor Author

BDisp commented Aug 30, 2023

I already fixed in the gui-cs/Terminal.Gui@c8f2d06, but it need wait until is merged and published.

BDisp added a commit to BDisp/TerminalGuiDesigner that referenced this issue Aug 30, 2023
@BDisp
Copy link
Contributor Author

BDisp commented Aug 30, 2023

Forget, throws the same error. I'll investigate the cause. Thanks for related this. I'll create a PR to this issue.

Done.

@tznind tznind closed this as completed in 91a1a22 Sep 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants