Table of Contents

Class Bar

Namespace
Terminal.Gui.Views
Assembly
Terminal.Gui.dll

A container for Shortcut items that arranges them horizontally or vertically. Serves as the base class for Menu, MenuBar, and StatusBar.

public class Bar : View, IDisposable, ISupportInitializeNotification, ISupportInitialize, IOrientation, IDesignable
Inheritance
Bar
Implements
Derived
Inherited Members
Extension Methods

Remarks

Any View can be added to a Bar. However, Bar is designed to work with Shortcut objects, which display a command, help text, and key binding aligned in a consistent order.

Orientation: The Orientation property controls the layout direction. In Horizontal mode, items are arranged left-to-right. In Vertical mode, items are stacked top-to-bottom and the MinimumKeyTextSize of each item is aligned to the widest key text across all items.

Auto-Sizing: Bar defaults to Dim.Auto(DimAutoStyle, Dim?, Dim?)() for both Width and Height, sizing itself based on its content.

Command Propagation: Sets CommandsToBubbleUp to [Accept, Activate], enabling commands from Shortcut items to bubble up through the Bar to parent views.

Separators: Line views can be added between Shortcut items to create visual separators. Lines are automatically oriented to match the Bar's Orientation.

Mouse Wheel: Mouse wheel events advance focus between items, enabling scrolling through items in the Bar.

Alignment: The AlignmentModes property controls how items are aligned within the Bar. The default is StartToEnd.

See Shortcut Deep Dive for details on the Shortcut items contained by Bar.

See Menus Deep Dive for how Bar fits into the menu system class hierarchy as the base of Menu and MenuBar.

Constructors

Bar()

Initializes a new instance of View.

Bar(IEnumerable<View>?)

Properties

AlignmentModes

Gets or sets the AlignmentModes for this Bar. The default is StartToEnd.

Orientation

Gets or sets the Orientation for this Bar. The default is Horizontal.

Methods

AddShortcutAt(int, Shortcut)

Inserts a Shortcut in the specified index of SubViews.

EnableForDesign()

Causes the View to enable design-time mode. This typically means that the view will load demo data and be configured to allow for design-time manipulation.

OnOrientationChanged(Orientation)

Called when Orientation has changed.

OnSubViewLayout(LayoutEventArgs)

Called from Terminal.Gui.ViewBase.View.LayoutSubViews before any subviews have been laid out.

RemoveShortcut(int)

Removes a Shortcut at specified index of SubViews.

Events

OrientationChanged

Raised when Orientation has changed.

OrientationChanging

Raised when Orientation is changing. Can be cancelled.