Class View | Terminal.Gui v2 (original) (raw)
Namespace
Assembly
Terminal.Gui.dll
View is the base class all visible elements. View can render itself and contains zero or more nested views, called SubViews. View provides basic functionality for layout, arrangement, and drawing. In addition, View provides keyboard and mouse event handling.
See the View Deep Dive for more.
public class View : IDisposable, ISupportInitializeNotification, ISupportInitialize
Inheritance
View
Implements
Derived
Inherited Members
Constructors
Initializes a new instance of View.
Properties
Gets or sets the user actions that are enabled for the arranging this view within it's SuperView.
The Adornment that offsets the Viewport from the Margin.
The Border provides the space for a visual border (drawn using line-drawing glyphs) and the Title. The Border expands inward; in other words if `Border.Thickness.Top == 2` the border and title will take up the first row and the second row will be filled with spaces.
The Border provides the UI for mouse and keyboard arrangement of the View. See Arrangement.
Gets or sets whether the view has a one row/col thick border.
Gets or sets a value indicating whether this View can be focused.
The color scheme for this view, if it is not defined, it returns the SuperView's color scheme.
Gets or sets a value indicating whether the view's content size tracks the Viewport's size or not.
Gets or sets the cursor style to be used when the view is focused. The default isInvisible.
Gets or sets arbitrary data for the view.
Gets or sets whether diagnostic information will be drawn. This is a bit-field of ViewDiagnosticFlags.e View diagnostics.
Points to the current driver in use by the view, it is a convenience property for simplifying the development of new views.
Gets or sets a value indicating whether this View can respond to user interaction.
Gets the currently focused SubView or Adornment of this view, or null if nothing is focused.
Gets or sets the absolute location and dimension of the view.
Gets or sets whether this view has focus.
Gets or sets the height dimension of the view.
Gets or sets whether the View will be highlighted visually by mouse interaction.
Gets the horizontal ScrollBar. This property is lazy-loaded and will not be created until it is accessed.
Gets or sets the hot key defined for this view. Pressing the hot key on the keyboard while this view has focus will invoke HotKey. By default, the HotKey is set to the first character of Textthat is prefixed with HotKeySpecifier.
A HotKey is a keypress that causes a visible UI item to perform an action. For example, in a Dialog, with a Button with the text of "_Text" Alt+T
will cause the button to gain focus and to raise itsAccepting event. Or, in aTerminal.Gui.Menu with "_File _Edit", Alt+F
will select (show) the "_File" menu. If the "_File" menu has a sub-menu of "_New" Alt+N
or N
will ONLY select the "_New" sub-menu if the "_File" menu is already opened.
View subclasses can use AddCommand(Command, CommandImplementation) to define the behavior of the hot key.
Gets the bindings for this view that will be invoked regardless of whether this view has focus or not.
Gets or sets the specifier character for the hot key (e.g. '_'). Set to '\xffff' to disable automatic hot key setting support for this View instance. The default is '\xffff'.
Gets or sets an identifier for the view;
Returns a value indicating if this View is currently on Top (Active)
Get or sets if the View has been initialized (via BeginInit()and EndInit()).
Gets the bindings for this view that will be invoked only if this view has focus.
The canvas that any line drawing that is to be shared by subviews of this view should add lines to.
The Adornment that enables separation of a View from other SubViews of the same SuperView. The margin offsets the Viewport from the Frame.
Returns the most focused SubView down the subview-hierarchy.
Gets the mouse bindings for this view.
Gets or sets whether the view needs to be redrawn.
Indicates the View's Frame or the layout of the View's subviews (including Adornments) have changed since the last time the View was laid out.
The Adornment inside of the view that offsets the Viewportfrom the Border.
Gets or sets whether trailing spaces at the end of word-wrapped lines are preserved or not when WordWrap is enabled. If true trailing spaces at the end of wrapped lines will be removed whenText is formatted for display. The default is false.
Gets or sets whether the View is shown with a shadow effect. The shadow is drawn on the right and bottom sides of the Margin.
Gets whether any SubViews need to be redrawn.
Gets the list of SubViews.
Gets this Views SuperView (the View's container), or null if this view has not been added as a SubView.
Gets or sets whether this View will use it's SuperView's LineCanvas for rendering any lines. If true the rendering of any borders drawn by this Frame will be done by its parent's SuperView. If false (the default) this View's OnDrawingAdornments() method will be called to render the borders.
Gets or sets the behavior of AdvanceFocus(NavigationDirection, TabBehavior?) for keyboard navigation.
The text displayed by the View.
Gets or sets how the View's Text is aligned horizontally when drawn. Changing this property will redisplay the View.
Gets or sets the direction of the View's Text. Changing this property will redisplay theView.
Gets or sets the TextFormatter used to format Text.
The title to be displayed for this View. The title will be displayed if Border.Top is greater than 0. The title can be used to set the HotKeyfor the view by prefixing character with HotKeySpecifier (e.g. "T_itle"
).
Gets or sets whether validation of Pos and Dim occurs.
Gets the vertical ScrollBar. This property is lazy-loaded and will not be created until it is accessed.
Gets or sets how the View's Text is aligned vertically when drawn. Changing this property will redisplay the View.
Gets or sets the rectangle describing the portion of the View's content that is visible to the user. The viewport Location is relative to the top-left corner of the inner rectangle of Padding. If the viewport Size is the same as GetContentSize(), or GetContentSize() isnull the Location will be 0, 0
.
Gets or sets how scrolling the Viewport on the View's Content Area is handled.
Gets or sets a value indicating whether this View is visible.
Gets or sets whether the View wants continuous button pressed events.
Gets or sets whether the View wants mouse position reports.
Gets or sets the width dimension of the view.
Gets or sets the X position for the view (the column).
Gets or sets the Y position for the view (the row).
Methods
Adds a SubView (child) to this view.
Adds the specified SubView (children) to the view.
AddCommand(Command, Func<bool?>)
Sets the function that will be invoked for a Command. Views should call AddCommand for each command they support.
If AddCommand has already been called for command
impl
will replace the old one.
AddCommand(Command, CommandImplementation)
Sets the function that will be invoked for a Command. Views should call AddCommand for each command they support.
If AddCommand has already been called for command
impl
will replace the old one.
AddKeyBindingsForHotKey(Key, Key, object?)
Adds key bindings for the specified HotKey. Useful for views that contain multiple items that each have their own HotKey such as RadioGroup.
Adds the specified char to the display at the current cursor position. This method is a convenience method that calls AddRune(Rune) with the Rune constructor.
Draws the specified character in the specified viewport-relative column and row of the View.
Draws the specified character at the current draw position.
Adds the str
to the display at the current draw position.
Changes the Clip to the intersection of the current Clip and the Viewport of this View.
AdvanceFocus(NavigationDirection, TabBehavior?)
Advances the focus to the next or previous view in the focus chain, based ondirection
. itself.
Signals the View that initialization is starting. See ISupportInitialize.
Clears any focus state (e.g. the previously focused subview) from this view.
Clears NeedsDraw and SubViewNeedsDraw.
Clears Viewport with the normal background.
Indicates whether the specified SuperView-relative coordinates are within the View's Frame.
Converts a Content-relative location to a Screen-relative location.
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resource.
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Invokes the Commands bound to key
.
See for an overview of Terminal.Gui keyboard APIs.
Draws the view if it needs to be drawn.
Causes Margin, Border, and Padding to be drawn.
Utility function to draw strings that contains a hotkey using a ColorScheme and the "focused" state.
DrawHotString(string, Attribute, Attribute)
Utility function to draw strings that contain a hotkey.
Draws the SubViews.
Draws the Text of the View using the TextFormatter.
Signals the View that initialization is ending. See ISupportInitialize.
Removes the specified rectangle from the Clip.
Removes the specified rectangle from the Clip.
Fills the specified Viewport-relative rectangle with the specified color.
Fills the specified Viewport-relative rectangle.
FocusDeepest(NavigationDirection, TabBehavior?)
Focuses the deepest focusable SubView if one exists. If there are no focusable SubViews then the focus is set to the view itself.
Gets the Frame with a screen-relative location.
Gets the thickness describing the sum of the Adornments' thicknesses.
Gets the current Attribute.
Gets the current Clip region.
Gets the size of the View's content.
Determines the current ColorScheme based on the Enabled value.
Gets the ColorScheme to use when the view is highlighted. The highlight colorscheme is based on the current ColorScheme, using GetHighlightColor().
Determines the current ColorScheme based on the Enabled value.
Determines the current ColorScheme based on the Enabled value.
Determines the current ColorScheme based on the Enabled value.
Returns all commands that are supported by this View.
Helper to get the X and Y offset of the Viewport from the Frame. This is the sum of the Left and Top properties of Margin, Border and Padding.
Invokes the specified command without context.
InvokeCommand(Command, ICommandContext?)
Invokes the specified command.
InvokeCommand(Command, TBindingType)
Invokes the specified command.
InvokeCommandsBoundToMouse(MouseEventArgs)
Invokes the Commands bound to the MouseFlags specified by mouseEventArgs
.
See for an overview of Terminal.Gui mouse APIs.
InvokeCommands(Command[], TBindingType)
Invokes the specified commands.
IsInHierarchy(View?, View?, bool)
Gets whether view
is in the SubView hierarchy of start
.
Performs layout of the view and its subviews using the content size of either the SuperView orScreen.
Performs layout of the view and its subviews within the specified content size.
Moves the drawing cursor to the specified Viewport-relative location in the view.
Moves subview
to the end of the SubViews list.
Moves subview
to the start of the SubViews list.
Moves subview
one position towards the end of the SubViews list.
Moves subview
one position towards the start of the SubViews list.
If the view is enabled, raises the related key down events on the view, and returns true if the event was handled.
If the view is enabled, raises the related key up events on the view, and returns true if the event was handled.
Processes a new MouseEvent. This method is called by RaiseMouseEvent(MouseEventArgs) when a mouse event occurs.
Called when the user is accepting the state of the View and the Accept has been invoked. Set CommandEventArgs.Cancel totrue and return true to stop processing.
OnAdvancingFocus(NavigationDirection, TabBehavior?)
Called when AdvanceFocus(NavigationDirection, TabBehavior?) is about to advance focus.
Called when the BorderStyle has changed.
Invoked when the CanFocus property from a view is changed.
Called when the Viewport has been cleared
Called when the Viewport is to be cleared.
OnCommandNotBound(CommandEventArgs)
Called when a command that has not been bound is invoked. Set CommandEventArgs.Cancel totrue and return true to cancel the event. The default implementation does nothing.
OnContentSizeChanged(SizeChangedEventArgs)
Called when GetContentSize() has changed.
Called when the View is completed drawing.
Called when the View's Adornments are to be drawn. Prepares LineCanvas. IfSuperViewRendersLineCanvas is true, only theLineCanvas of this view's subviews will be rendered. If SuperViewRendersLineCanvas is false (the default), this method will cause the LineCanvas be prepared to be rendered.
Called when the View's content is to be drawn. The default implementation does nothing.
OnDrawingContent(DrawContext?)
Called when the View's content is to be drawn. The default implementation does nothing.
Called when the SubViews are to be drawn.
OnDrawingSubViews(DrawContext?)
Called when the SubViews are to be drawn.
Called when the Text of the View is to be drawn.
Called when the Text of the View is to be drawn.
Invoked when the Enabled property from a view is changed.
OnFocusedChanged(View?, View?)
Called when the focused view has changed.
Called when Frame changes.
OnHandlingHotKey(CommandEventArgs)
Called when the View is handling the user pressing the View's HotKey. Set CommandEventArgs.Cancel totrue to stop processing.
OnHasFocusChanged(bool, View?, View?)
Invoked after HasFocus has changed. This method is called before the HasFocusChangedevent is raised.
OnHasFocusChanging(bool, bool, View?, View?)
Invoked when HasFocus is about to change. This method is called before theHasFocusChanging event is raised.
Called when the view is to be highlighted. The HighlightStyle passed in the event indicates the highlight style that will be applied. The view can modify the highlight style by setting theNewValue property.
Called when the user presses a key, allowing subscribers to pre-process the key down event. Called before key bindings are invoked and KeyDownNotHandled is raised. SetHandledto true to stop the key from being processed further.
Called when the user has pressed key it wasn't handled by KeyDown and was not bound to a key binding.
Called when a key is released. This method is called from NewKeyUpEvent(Key).
Called when a mouse click occurs. Check Flags to see which button was clicked.
Called when the mouse moves over the View's Frame and no other non-SubView occludes it.MouseLeave will be raised when the mouse is no longer over the Frame.
Called when a mouse event occurs within the view's Viewport.
Called when the mouse moves outside View's Frame, or is occluded by another non-SubView.
Called when a mouse wheel event occurs. Check Flags to see which wheel was moved was clicked.
Called when the LineCanvas is to be rendered. See RenderLineCanvas().
Called when the user has performed an action (e.g. Select) causing the View to change state. Set CommandEventArgs.Cancel totrue and return true to cancel the state change. The default implementation does nothing.
Called when the normal attribute for the View is to be set. This is called before the View is drawn.
Called when a SubView has been added to this View.
OnSubViewLayout(LayoutEventArgs)
Called from Terminal.Gui.View.LayoutSubViews() before any subviews have been laid out.
Called when a SubView has been removed from this View.
OnSubViewsLaidOut(LayoutEventArgs)
Called from Terminal.Gui.View.LayoutSubViews() after all sub-views have been laid out.
OnSuperViewChanged(SuperViewChangedEventArgs)
Called when the SuperView of this View has changed.
Called when the Text has changed. Fires the TextChanged event.
Called when the Title has been changed. Invokes the TitleChanged event.
Called before the Title changes. Invokes the TitleChanging event, which can be cancelled.
OnViewportChanged(DrawEventArgs)
Called when the Viewport changes. Invokes the ViewportChanged event.
Called when Visible has changed.
Called when Visible is changing. Can be cancelled by returning true.
Positions the cursor in the right position based on the currently focused view in the chain.
RaiseAccepting(ICommandContext?)
Called when the user is accepting the state of the View and the Accept has been invoked. Calls OnAccepting(CommandEventArgs) which can be cancelled; if not cancelled raises Accepting. event. The default Accept handler calls this method.
RaiseCommandNotBound(ICommandContext?)
Called when a command that has not been bound is invoked.
Called when the View is handling the user pressing the View's HotKeys. Calls OnHandlingHotKey(CommandEventArgs) which can be cancelled; if not cancelled raises Accepting. event. The default HotKey handler calls this method.
RaiseMouseClickEvent(MouseEventArgs)
Raises the OnMouseClick(MouseEventArgs)/MouseClick event.
RaiseMouseEvent(MouseEventArgs)
Raises the RaiseMouseEvent(MouseEventArgs)/MouseEvent event.
RaiseMouseWheelEvent(MouseEventArgs)
Raises the OnMouseWheel(MouseEventArgs)/MouseWheel event.
RaiseSelecting(ICommandContext?)
Called when the user has performed an action (e.g. Select) causing the View to change state. Calls OnSelecting(CommandEventArgs) which can be cancelled; if not cancelled raises Accepting. event. The default Select handler calls this method.
Removes a SubView added via Add(View?) or Add(params View[]?) from this View.
Removes all SubViews added via Add(View?) or Add(params View[]?) from this View.
Removes all SubViews of a type added via Add(View?) or Add(params View[]?) from this View.
Causes the contents of LineCanvas to be drawn. If SuperViewRendersLineCanvas is true, only theLineCanvas of this view's subviews will be rendered. If SuperViewRendersLineCanvas is false (the default), this method will cause the LineCanvas to be rendered.
Converts a Screen-relative coordinate to a Content-relative coordinate.
Converts a screen-relative coordinate to a Frame-relative coordinate. Frame-relative means relative to the View's SuperView's Viewport.
Converts a screen-relative coordinate to a Viewport-relative coordinate.
Scrolls the view horizontally by the specified number of columns.
Scrolls the view vertically by the specified number of rows.
Selects the specified attribute as the attribute to use for future calls to AddRune and AddString.
Sets the Clip to the specified region.
Sets the Clip to be the rectangle of the screen.
Sets the size of the View's content.
Causes this view to be focused. Calling this method has the same effect as setting HasFocus totrue but with the added benefit of returning a value indicating whether the focus was set.
Sets that the Viewport of this View needs to be redrawn.
Expands the area of this view needing to be redrawn to include viewPortRelativeRegion
.
Sets NeedsLayout to return true, indicating this View and all of it's subviews (including adornments) need to be laid out in the next Application iteration.
Sets the Normal attribute if the setting process is not canceled. It triggers an event and checks for cancellation before proceeding.
Sets the position and size of this view, relative to the SuperView's ContentSize (nominally the same asthis.SuperView.GetContentSize ()
) based on the values of X, Y,Width, and Height.
Sets SubViewNeedsDraw to true for this View and all Superviews.
Pretty prints the View
Can be overridden if the Text has different format than the default.
Gets the Viewport rectangle with a screen-relative location.
Converts a Viewport-relative location to a screen-relative location.
ViewportToScreen(in Rectangle)
Converts a Viewport-relative location and size to a screen-relative location and size.
Events
Cancelable event raised when the user is accepting the state of the View and the Accept has been invoked. Set CommandEventArgs.Cancel to cancel the event.
Raised when AdvanceFocus(NavigationDirection, TabBehavior?) is about to advance focus.
Fired when the BorderStyle has changed.
Raised when CanFocus has been changed.
Event invoked when the Viewport has been cleared.
Event invoked when the Viewport is to be cleared.
Cancelable event raised when a command that has not been bound is invoked.
Event raised when the GetContentSize() changes.
Riased when the View is being disposed.
Raised when the View is completed drawing.
Raised when the View's content is to be drawn.
Raised when the SubViews are to be drawn.
Raised when the Text of the View is to be drawn.
Raised when the Enabled value is being changed.
Raised when the focused view has changed.
Raised when the Frame changes. This event is raised after the Frame has been updated.
Raised the Focus Color is being retrieved, from GetFocusColor(). Cancel the event and set the new attribute in the event args to a different value to change the focus color.
Raised the HotFocus Color is being retrieved, from GetHotFocusColor(). Cancel the event and set the new attribute in the event args to a different value to change the focus color.
Raised the HotNormal Color is being retrieved, from GetHotNormalColor(). Cancel the event and set the new attribute in the event args to a different value to change the focus color.
Raised the Normal Color is being retrieved, from GetNormalColor(). Cancel the event and set the new attribute in the event args to a different value to change the focus color.
Cancelable event raised when the View is handling the user pressing the View's HotKey. Set CommandEventArgs.Cancel to cancel the event.
Raised after HasFocus has changed.
Raised when HasFocus is about to change.
Raised when the view is to be highlighted. The HighlightStyle passed in the event indicates the highlight style that will be applied. The view can modify the highlight style by setting theNewValue property. Set to true, to cancel, indicating custom highlighting.
Raised when the HotKey is changed.
Raised once when the View is being initialized for the first time. Allows configurations and assignments to be performed before the View being shown. View implements ISupportInitializeNotification to allow for more sophisticated initialization.
Raised when the user presses a key, allowing subscribers to pre-process the key down event. Called before key bindings are invoked and KeyDownNotHandled is raised. SetHandledto true to stop the key from being processed further.
Raised when the user has pressed key it wasn't handled by KeyDown and was not bound to a key binding.
Raised when a key is released. Set Handled to true to stop the key up event from being processed by other views.Not all terminals support key distinct down/up notifications, Applications should avoid depending on distinct KeyDown and KeyUp events and instead should use KeyDown.
See for an overview of Terminal.Gui keyboard APIs.
Raised when a mouse click occurs.
Raised when the mouse moves over the View's Frame. MouseLeave will be raised when the mouse is no longer over the Frame. If another View occludes this View, the that View will also receive MouseEnter/Leave events.
Raised when a mouse event occurs.
Raised when the mouse moves outside View's Frame, or is occluded by another non-SubView.
Raised when a mouse wheel event occurs.
Raised when a SubView has been removed from this View.
Cancelable event raised when the user has performed an action (e.g. Select) causing the View to change state. CommandEventArgs.Cancel to true to cancel the state change.
Raised when the normal attribute for the View is to be set. This is raised before the View is drawn.
Raised when a SubView has been added to this View.
Raised by Terminal.Gui.View.LayoutSubViews() before any subviews have been laid out.
Raised when a SubView has been added to this View.
Raised after all sub-views have been laid out.
Raised when the SuperView of this View has changed.
Text changed event, raised when the text has changed.
Raised after the Title has been changed.
Raised when the Title is changing. Set Cancel to true
to cancel the Title change.
Fired when the Viewport changes. This event is fired after the Viewport has been updated.
Raised when Visible has changed.
Raised when the Visible value is being changed. Can be cancelled by setting Cancel totrue.