question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

StatusBar Multiple Instances

See original GitHub issue

I’m starting to work with Terminal.Gui and right now have implemented several instances of Toplevel for different “screens” in my program. (I don’t want borders/title drawn as would happen with a Window, but I do want a StatusBar for each Toplevel.)

The first Toplevel that gets created with a new StatusBar() looks fine, but all subsequent Toplevel views do not have a visible new StatusBar(); additionally, hot-key functions are usable even without a visible StatusBar.

I see there’s StatusBar property on the Toplevel. If I try assigning a new StatusBar() to this property, all views get a visible StatusBar but the first view has an “extra” blank line which ends up with a “ghost” StatusBar when the views are switched.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9

github_iconTop GitHub Comments

2reactions
rmorales87atxcommented, May 26, 2021

Thank you all for the code samples! This looks decent 👍

1reaction
BDispcommented, May 25, 2021

You are right. See the demo.cs in the Example project which has a similar approach.

Sorry @tznind. I gave you wrong information. Application.Init (); doesn’t do nothing to acquire the needed behavior, because the driver and Appliaction.Top are already setup. It’s the var top = Application.Top; who do what it’s intended to do, because only the Application.Top can have a MenuBar and a StatusBar. But we must be careful to cleanup all the Application.Top subviews, before assign it to a new Toplevel. So, here is a changed example:

class Program {
	static void Main (string [] args)
	{
		Application.Init ();

		Load (MainTop ());

		Application.Shutdown ();
	}

	private static Toplevel MainTop ()
	{
		var top = NewTop ();

		top.Add (new Label ("Window1"));

		var sb = new StatusBar (new [] {
			new StatusItem(Key.CtrlMask | Key.Q, "~^Q~ Exit", () => Application.RequestStop()),
			new StatusItem(Key.CtrlMask | Key.T, "~^T~ Next", () => Load(SecondTop()))
		});
		top.Add (sb);

		return top;
	}

	private static Toplevel SecondTop ()
	{
		var top = NewTop ();

		top.Add (new Label ("Window2"));

		var sb = new StatusBar (new [] {
			new StatusItem(Key.CtrlMask | Key.Q, "~^Q~ Exit", () => Application.RequestStop()),
			new StatusItem(Key.CtrlMask | Key.P, "~^P~ Previous", () => Load(MainTop())),
			new StatusItem(Key.CtrlMask | Key.T, "~^T~ Next", () => Load(ThirdTop()))
		});
		top.Add (sb);

		return top;
	}

	private static Toplevel ThirdTop ()
	{
		var top = NewTop ();

		top.Add (new Label ("Window3"));

		var sb = new StatusBar (new [] {
			new StatusItem(Key.CtrlMask | Key.Q, "~^Q~ Exit", () => Application.RequestStop()),
				new StatusItem(Key.CtrlMask | Key.P, "~^P~ Previous", () => Load(SecondTop()))
		});
		top.Add (sb);

		return top;
	}

	private static void Load (Toplevel top)
	{
		Application.Run (top);
	}

	private static Toplevel NewTop ()
	{
		Application.Top.RemoveAll ();
		return Application.Top;
	}
}

Read more comments on GitHub >

github_iconTop Results From Across the Web

Excel Status Bar and Multiple Instances of Excel
Excel Status Bar and Multiple Instances of Excel · Right-click the current Excel window in the taskbar. · While holding down ALT &...
Read more >
Multiple Instances of StatusBar or ProgressBar plugin #788
I'm currently using Uppy in a dynamic form system which allows users to completely customize the fields they use for our product.
Read more >
Android Activity with 2 status bar?
1 Answer 1 ... The status bar is not part of the Activity. Of course, you can design your Activity UI to have...
Read more >
Multiple dzen2 instances to make single status bar : r/i3wm
Hey, I'm trying to make a single status bar in i3, which I am trying to run with multiple instances of dzen2 to...
Read more >
StatusBar
It is possible to have multiple StatusBar components mounted at the same time. The props will be merged in the order the StatusBar...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found