Class Toplevel
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
Toplevel views can run as modal (popup) views, started by calling
Run(Toplevel, Func<Exception, bool>?). 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>?).
Constructors
- Toplevel()
Initializes a new instance of the Toplevel class, defaulting to full screen. The Width and Height properties will be set to the dimensions of the terminal using Fill(Dim).
Properties
- IsLoaded
true if was already loaded by the Begin(Toplevel)false, otherwise.
- 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).
true
:- OnKeyDown(Key) events will NOT propagate keys upwards.
- The Toplevel will and look like a modal (pop-up) (e.g. see Dialog.
Methods
- OnLoaded()
Called from Begin(Toplevel) before the Toplevel redraws for the first time.
- PositionToplevel(Toplevel?)
Adjusts the location and size of
top
within this Toplevel. Virtual method enabling implementation of specific positions for inherited Toplevel views.
- RequestStop()
Stops and closes this Toplevel. If this Toplevel is the top-most Toplevel, RequestStop(Toplevel?) will be called, causing the application to exit.
Events
- 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 active.
- 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).
- 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>?) 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).