Table of Contents

Class Toplevel

Namespace
Terminal.Gui
Assembly
Terminal.Gui.dll

Toplevel views are used for both an application's main view (filling the entire screen and for modal (pop-up) views such as Dialog, MessageBox, and Wizard).

public class Toplevel : View, IDisposable, ISupportInitializeNotification, ISupportInitialize
Inheritance
Toplevel
Implements
Derived
Inherited Members

Remarks

Toplevels can run as modal (popup) views, started by calling Run(Toplevel, Func<Exception, bool>, ConsoleDriver). They return control to the caller when RequestStop(Toplevel) has been called (which sets the Running property to false).

A Toplevel is created when an application initializes Terminal.Gui by calling Init(ConsoleDriver, string). The application Toplevel can be accessed via Top. Additional Toplevels can be created and run (e.g. Dialogs. To run a Toplevel, create the Toplevel and call Run(Toplevel, Func<Exception, bool>, ConsoleDriver).

Constructors

Toplevel()

Initializes a new instance of the Toplevel class with Computed layout, defaulting to full screen. The Width and Height properties will be set to the dimensions of the terminal using Fill(int).

Properties

IsLoaded

true if was already loaded by the Begin(Toplevel)false, otherwise.

IsOverlapped

Gets or sets if this Toplevel is in overlapped mode within a Toplevel container.

IsOverlappedContainer

Gets or sets if this Toplevel is a container for overlapped children.

MenuBar

Gets or sets the menu for this Toplevel.

Modal

Determines whether the Toplevel is modal or not. If set to false (the default):

  • OnKeyDown(Key) events will propagate keys upwards.
  • The Toplevel will act as an embedded view (not a modal/pop-up).
If set to true:
  • OnKeyDown(Key) events will NOT propagate keys upwards.
  • The Toplevel will and look like a modal (pop-up) (e.g. see Dialog.
Running

Gets or sets whether the main loop for this Toplevel is running or not.

StatusBar

Gets or sets the status bar for this Toplevel.

Methods

Add(View)

Adds a subview (child) to this view.

OnAlternateBackwardKeyChanged(KeyChangedEventArgs)

Virtual method to invoke the AlternateBackwardKeyChanged event.

OnAlternateForwardKeyChanged(KeyChangedEventArgs)

Virtual method to invoke the AlternateForwardKeyChanged event.

OnDrawContent(Rectangle)

Draws the view's content, including Subviews.

OnEnter(View)

Called when a view gets focus.

OnLeave(View)

Method invoked when a view loses focus.

OnLoaded()

Called from Begin(Toplevel) before the Toplevel redraws for the first time.

OnQuitKeyChanged(KeyChangedEventArgs)

Virtual method to invoke the QuitKeyChanged event.

PositionCursor()

Positions the cursor in the right position based on the currently focused view in the chain.

PositionToplevel(Toplevel)

Adjusts the location and size of top within this Toplevel. Virtual method enabling implementation of specific positions for inherited Toplevel views.

Remove(View)

Removes a subview added via Add(View) or Add(params View[]) from this View.

RemoveAll()

Removes all subviews (children) added via Add(View) or Add(params View[]) from this View.

RequestStop()

Stops and closes this Toplevel. If this Toplevel is the top-most Toplevel, RequestStop(Toplevel) will be called, causing the application to exit.

RequestStop(Toplevel)

Stops and closes the Toplevel specified by top. If top is the top-most Toplevel, RequestStop(Toplevel) will be called, causing the application to exit.

Events

Activate

Invoked when the Toplevel RunState becomes the Current Toplevel.

AllChildClosed

Invoked when the last child of the Toplevel RunState is closed from by End(RunState).

AlternateBackwardKeyChanged

Invoked when the AlternateBackwardKey is changed.

AlternateForwardKeyChanged

Invoked when the AlternateForwardKey is changed.

ChildClosed

Invoked when a child of the Toplevel RunState is closed by End(RunState).

ChildLoaded

Invoked when a child Toplevel's RunState has been loaded.

ChildUnloaded

Invoked when a cjhild Toplevel's RunState has been unloaded.

Closed

Invoked when the Toplevel's RunState is closed by End(RunState).

Closing

Invoked when the Toplevel's RunState is being closed by RequestStop(Toplevel).

Deactivate

Invoked when the ToplevelRunState ceases to be the Current Toplevel.

Loaded

Invoked when the ToplevelRunState has begun to be loaded. A Loaded event handler is a good place to finalize initialization before calling RunLoop(RunState).

QuitKeyChanged

Invoked when the QuitKey is changed.

Ready

Invoked when the Toplevel main loop has started it's first iteration. Subscribe to this event to perform tasks when the Toplevel has been laid out and focus has been set. changes.

A Ready event handler is a good place to finalize initialization after calling Run(Toplevel, Func<Exception, bool>, ConsoleDriver) on this Toplevel.

SizeChanging

Invoked when the terminal has been resized. The new Size of the terminal is provided.

Unloaded

Invoked when the Toplevel RunState has been unloaded. A Unloaded event handler is a good place to dispose objects after calling End(RunState).