Class Toplevel
Toplevel views can be modally executed. They are used for both an application's main view (filling the entire screen and for 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 be modally executing 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, IMainLoopDriver). 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>).
Toplevels can also opt-in to more sophisticated initialization by implementing ISupportInitialize. When they do so, the BeginInit() and EndInit() methods will be called before running the view. If first-run-only initialization is preferred, the ISupportInitializeNotification can be implemented too, in which case the ISupportInitialize methods will only be called if IsInitialized is false. This allows proper View inheritance hierarchies to override base class layout code optimally by doing so only on first run, instead of on every run.
Constructors
- Toplevel()
Initializes a new instance of the Toplevel class with Computed layout, defaulting to full screen.
- Toplevel(Rect)
Initializes a new instance of the Toplevel class with the specified Absolute layout.
Properties
- IsMdiChild
Gets or sets if this Toplevel is a Mdi child.
- IsMdiContainer
Gets or sets if this Toplevel is a Mdi container.
- MenuBar
Gets or sets the menu for this Toplevel.
- Modal
Determines whether the Toplevel is modal or not. If set to
false
(the default):- ProcessKey(KeyEvent) events will propagate keys upwards.
- The Toplevel will act as an embedded view (not a modal/pop-up).
If set to
true
:- ProcessKey(KeyEvent) events will NOT propogate keys upwards.
- The Toplevel will and look like a modal (pop-up) (e.g. see Dialog.
- StatusBar
Gets or sets the status bar for this Toplevel.
Methods
- Add(View)
Adds a subview (child) to this view.
- Create()
Convenience factory method that creates a new Toplevel with the current terminal dimensions.
- Dispose(bool)
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- GetTopMdiChild(Type, string[])
Gets the current visible Toplevel Mdi child that matches the arguments pattern.
- MouseEvent(MouseEvent)
Method invoked when a mouse event is generated
- MoveNext()
Move to the next Mdi child from the MdiTop.
- MovePrevious()
Move to the previous Mdi child from the MdiTop.
- OnAlternateBackwardKeyChanged(Key)
Virtual method to invoke the AlternateBackwardKeyChanged event.
- OnAlternateForwardKeyChanged(Key)
Virtual method to invoke the AlternateForwardKeyChanged event.
- OnEnter(View)
Method invoked when a view gets focus.
- OnKeyDown(KeyEvent)
Method invoked when a key is pressed.
- OnKeyUp(KeyEvent)
Method invoked when a key is released.
- OnLeave(View)
Method invoked when a view loses focus.
- OnLoaded()
Called from Begin(Toplevel) before the Toplevel redraws for the first time.
- OnQuitKeyChanged(Key)
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)
Virtual method enabling implementation of specific positions for inherited Toplevel views.
- ProcessColdKey(KeyEvent)
This method can be overwritten by views that want to provide accelerator functionality (Alt-key for example), but without interefering with normal ProcessKey behavior.
- ProcessHotKey(KeyEvent)
This method can be overwritten by view that want to provide accelerator functionality (Alt-key for example).
- ProcessKey(KeyEvent)
If the view is focused, gives the view a chance to process the keystroke.
- Redraw(Rect)
Redraws this view and its subviews; only redraws the views that have been flagged for a re-display.
- 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
. Iftop
is the top-most Toplevel, RequestStop(Toplevel) will be called, causing the application to exit.
- ShowChild(Toplevel)
Shows the Mdi child indicated by
top
, setting it as Current.
- WillPresent()
Invoked by Begin(Toplevel) as part of Run(Toplevel, Func<Exception, bool>) after the views have been laid out, and before the views are drawn for the first time.
Events
- Activate
Invoked when the Toplevel Application.RunState becomes the Current Toplevel.
- AllChildClosed
Invoked when the last child of the Toplevel Application.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 Application.RunState is closed by
End(RunState).
- ChildLoaded
Invoked when a child Toplevel's Application.RunState has been loaded.
- ChildUnloaded
Invoked when a cjhild Toplevel's Application.RunState has been unloaded.
- Closed
Invoked when the Toplevel's Application.RunState is closed by End(RunState).
- Closing
Invoked when the Toplevel's Application.RunState is being closed by
RequestStop(Toplevel).
- Deactivate
Invoked when the ToplevelApplication.RunState ceases to be the Current Toplevel.
- Loaded
Invoked when the Toplevel Application.RunState has begun to be loaded. A Loaded event handler is a good place to finalize initialization before calling RunLoop(RunState, bool).
- QuitKeyChanged
Invoked when the QuitKey is changed.
- Ready
Invoked when the Toplevel MainLoop 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(Func<Exception, bool>) on this Toplevel.
- Unloaded
Invoked when the Toplevel Application.RunState has been unloaded. A Unloaded event handler is a good place to dispose objects after calling End(RunState).