Search Results for

Show / Hide Table of Contents

# Class View

View is the base class for all views on the screen and represents a visible element that can render itself and contains zero or more nested views.

##### Inheritance

System.Object
Responder
View
Button
CheckBox
ComboBox
FrameView
GraphView
HexView
Label
ListView
MenuBar
PanelView
ProgressBar
RadioGroup
ScrollBarView
ScrollView
StatusBar
TableView
TabView
TextField
TextValidateField
TextView
Toplevel
TreeView<T>
LineView

##### Implements

System.IDisposable
System.ComponentModel.ISupportInitializeNotification
System.ComponentModel.ISupportInitialize

##### Inherited Members

Responder.MouseEvent(MouseEvent)
Responder.Dispose()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)

###### Namespace: Terminal.Gui

###### Assembly: Terminal.Gui.dll

##### Syntax

    public class View : Responder, IDisposable, ISupportInitializeNotification, ISupportInitialize

##### Remarks

The View defines the base functionality for user interface elements in Terminal.Gui. Views can contain one or more subviews, can respond to user input and render themselves on the screen.

Views supports two layout styles: Absolute or Computed. The choice as to which layout style is used by the View is determined when the View is initialized. To create a View using Absolute layout, call a constructor that takes a Rect parameter to specify the absolute position and size (the `View.Frame`)/. To create a View using Computed layout use a constructor that does not take a Rect parameter and set the X, Y, Width and Height properties on the view. Both approaches use coordinates that are relative to the container they are being added to.

To switch between Absolute and Computed layout, use the LayoutStyle property.

Computed layout is more flexible and supports dynamic console apps where controls adjust layout as the terminal resizes or other Views change size or position. The X, Y, Width and Height properties are Dim and Pos objects that dynamically update the position of a view. The X and Y properties are of type Pos and you can use either absolute positions, percentages or anchor points. The Width and Height properties are of type Dim and can use absolute position, percentages and anchors. These are useful as they will take care of repositioning views when view's frames are resized or if the terminal size changes.

Absolute layout requires specifying coordinates and sizes of Views explicitly, and the View will typically stay in a fixed position and size. To change the position and size use the Frame property.

Subviews (child views) can be added to a View by calling the Add(View) method. The container of a View can be accessed with the SuperView property.

To flag a region of the View's Bounds to be redrawn call SetNeedsDisplay(Rect). To flag the entire view for redraw call SetNeedsDisplay().

Views have a ColorScheme property that defines the default colors that subviews should use for rendering. This ensures that the views fit in the context where they are being used, and allows for themes to be plugged in. For example, the default colors for windows and toplevels uses a blue background, while it uses a white background for dialog boxes and a red background for errors.

Subclasses should not rely on ColorScheme being set at construction time. If a ColorScheme is not set on a view, the view will inherit the value from its SuperView and the value might only be valid once a view has been added to a SuperView.

By using ColorScheme applications will work both in color as well as black and white displays.

Views that are focusable should implement the PositionCursor() to make sure that the cursor is placed in a location that makes sense. Unix terminals do not have a way of hiding the cursor, so it can be distracting to have the cursor left at the last focused view. So views should make sure that they place the cursor in a visually sensible place.

The LayoutSubviews() method is invoked when the size or layout of a view has changed. The default processing system will keep the size and dimensions for views that use the Absolute, and will recompute the frames for the vies that use Computed.

### Constructors

#### View()

Initializes a new instance of View using Computed layout.

##### Declaration

    public View()

##### Remarks

Use X, Y, Width, and Height properties to dynamically control the size and location of the view. The Label will be created using Computed coordinates. The initial size (Frame will be adjusted to fit the contents of Text, including newlines ('\n') for multiple lines.

If `Height` is greater than one, word wrapping is provided.

This constructor initialize a View with a LayoutStyle of Computed. Use X, Y, Width, and Height properties to dynamically control the size and location of the view.

#### View(ustring, TextDirection, Border)

Initializes a new instance of View using Computed layout.

##### Declaration

    public View(ustring text, TextDirection direction = TextDirection.LeftRight_TopBottom, Border border = null)

##### Parameters

Type | Name | Description
--- | --- | ---
NStack.ustring | text | text to initialize the Text property with.
TextDirection | direction | The text direction.
Border | border | The Border.

##### Remarks

The View will be created using Computed coordinates with the given string. The initial size (Frame will be adjusted to fit the contents of Text, including newlines ('\n') for multiple lines.

If `Height` is greater than one, word wrapping is provided.

#### View(Int32, Int32, ustring)

Initializes a new instance of View using Absolute layout.

##### Declaration

    public View(int x, int y, ustring text)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | x | column to locate the Label.
System.Int32 | y | row to locate the Label.
NStack.ustring | text | text to initialize the Text property with.

##### Remarks

The View will be created at the given coordinates with the given string. The size (Frame will be adjusted to fit the contents of Text, including newlines ('\n') for multiple lines.

No line wrapping is provided.

#### View(Rect)

Initializes a new instance of a Absolute View class with the absolute dimensions specified in the `frame` parameter.

##### Declaration

    public View(Rect frame)

##### Parameters

Type | Name | Description
--- | --- | ---
Rect | frame | The region covered by this view.

##### Remarks

This constructor initialize a View with a LayoutStyle of Absolute. Use View() to initialize a View with LayoutStyle of Computed

#### View(Rect, ustring, Border)

Initializes a new instance of View using Absolute layout.

##### Declaration

    public View(Rect rect, ustring text, Border border = null)

##### Parameters

Type | Name | Description
--- | --- | ---
Rect | rect | Location.
NStack.ustring | text | text to initialize the Text property with.
Border | border | The Border.

##### Remarks

The View will be created at the given coordinates with the given string. The initial size (Frame will be adjusted to fit the contents of Text, including newlines ('\n') for multiple lines.

If `rect.Height` is greater than one, word wrapping is provided.

### Properties

#### AutoSize

Used by Text to resize the view's Bounds with the Size. Setting AutoSize to true only work if the Width and Height are null or Absolute values and doesn't work with Computed layout, to avoid breaking the Pos and Dim settings.

##### Declaration

    public virtual bool AutoSize { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

#### Border

##### Declaration

    public virtual Border Border { get; set; }

##### Property Value

Type | Description
--- | ---
Border |

#### Bounds

The bounds represent the View-relative rectangle used for this view; the area inside of the view.

##### Declaration

    public Rect Bounds { get; set; }

##### Property Value

Type | Description
--- | ---
Rect | The bounds.

##### Remarks

Updates to the Bounds update the Frame, and has the same side effects as updating the Frame.

Because Bounds coordinates are relative to the upper-left corner of the View, the coordinates of the upper-left corner of the rectangle returned by this property are (0,0). Use this property to obtain the size and coordinates of the client area of the control for tasks such as drawing on the surface of the control.

#### CanFocus

##### Declaration

    public override bool CanFocus { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

##### Overrides

Responder.CanFocus

#### ColorScheme

The color scheme for this view, if it is not defined, it returns the SuperView's color scheme.

##### Declaration

    public virtual ColorScheme ColorScheme { get; set; }

##### Property Value

Type | Description
--- | ---
ColorScheme |

#### Data

Gets or sets arbitrary data for the view.

##### Declaration

    public object Data { get; set; }

##### Property Value

Type | Description
--- | ---
System.Object |

##### Remarks

This property is not used internally.

#### Driver

Points to the current driver in use by the view, it is a convenience property for simplifying the development of new views.

##### Declaration

    public static ConsoleDriver Driver { get; }

##### Property Value

Type | Description
--- | ---
ConsoleDriver |

#### Enabled

##### Declaration

    public override bool Enabled { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

##### Overrides

Responder.Enabled

#### Focused

Returns the currently focused view inside this view, or null if nothing is focused.

##### Declaration

    public View Focused { get; }

##### Property Value

Type | Description
--- | ---
View | The focused.

#### Frame

Gets or sets the frame for the view. The frame is relative to the view's container (SuperView).

##### Declaration

    public virtual Rect Frame { get; set; }

##### Property Value

Type | Description
--- | ---
Rect | The frame.

##### Remarks

Change the Frame when using the Absolute layout style to move or resize views.

Altering the Frame of a view will trigger the redrawing of the view as well as the redrawing of the affected regions of the SuperView.

#### HasFocus

##### Declaration

    public override bool HasFocus { get; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

##### Overrides

Responder.HasFocus

#### Height

Gets or sets the height of the view. Only used the LayoutStyle is Computed.

##### Declaration

    public Dim Height { get; set; }

##### Property Value

Type | Description
--- | ---
Dim | The height.

#### HotKey

Gets or sets the HotKey defined for this view. A user pressing HotKey on the keyboard while this view has focus will cause the Clicked event to fire.

##### Declaration

    public virtual Key HotKey { get; set; }

##### Property Value

Type | Description
--- | ---
Key |

#### HotKeySpecifier

Gets or sets the specifier character for the hotkey (e.g. '_'). Set to '\xffff' to disable hotkey support for this View instance. The default is '\xffff'.

##### Declaration

    public virtual Rune HotKeySpecifier { get; set; }

##### Property Value

Type | Description
--- | ---
System.Rune |

#### Id

Gets or sets an identifier for the view;

##### Declaration

    public ustring Id { get; set; }

##### Property Value

Type | Description
--- | ---
NStack.ustring | The identifier.

##### Remarks

The id should be unique across all Views that share a SuperView.

#### IsCurrentTop

Returns a value indicating if this View is currently on Top (Active)

##### Declaration

    public bool IsCurrentTop { get; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

#### IsInitialized

Get or sets if the View was already initialized. This derived from System.ComponentModel.ISupportInitializeNotification to allow notify all the views that are being initialized.

##### Declaration

    public virtual bool IsInitialized { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

#### LayoutStyle

Controls how the View's Frame is computed during the LayoutSubviews method, if the style is set to Absolute, LayoutSubviews does not change the Frame. If the style is Computed the Frame is updated using the X, Y, Width, and Height properties.

##### Declaration

    public LayoutStyle LayoutStyle { get; set; }

##### Property Value

Type | Description
--- | ---
LayoutStyle | The layout style.

#### MostFocused

Returns the most focused view in the chain of subviews (the leaf view that has the focus).

##### Declaration

    public View MostFocused { get; }

##### Property Value

Type | Description
--- | ---
View | The most focused.

#### Shortcut

This is the global setting that can be used as a global shortcut to invoke an action if provided.

##### Declaration

    public Key Shortcut { get; set; }

##### Property Value

Type | Description
--- | ---
Key |

#### ShortcutAction

The action to run if the Shortcut is defined.

##### Declaration

    public virtual Action ShortcutAction { get; set; }

##### Property Value

Type | Description
--- | ---
System.Action |

#### ShortcutTag

The keystroke combination used in the Shortcut as string.

##### Declaration

    public ustring ShortcutTag { get; }

##### Property Value

Type | Description
--- | ---
NStack.ustring |

#### Subviews

This returns a list of the subviews contained by this view.

##### Declaration

    public IList<View> Subviews { get; }

##### Property Value

Type | Description
--- | ---
System.Collections.Generic.IList<View> | The subviews.

#### SuperView

Returns the container for this view, or null if this view has not been added to a container.

##### Declaration

    public View SuperView { get; }

##### Property Value

Type | Description
--- | ---
View | The super view.

#### TabIndex

Indicates the index of the current View from the TabIndexes list.

##### Declaration

    public int TabIndex { get; set; }

##### Property Value

Type | Description
--- | ---
System.Int32 |

#### TabIndexes

This returns a tab index list of the subviews contained by this view.

##### Declaration

    public IList<View> TabIndexes { get; }

##### Property Value

Type | Description
--- | ---
System.Collections.Generic.IList<View> | The tabIndexes.

#### TabStop

This only be `true` if the CanFocus is also `true` and the focus can be avoided by setting this to `false`

##### Declaration

    public bool TabStop { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

#### Text

The text displayed by the View.

##### Declaration

    public virtual ustring Text { get; set; }

##### Property Value

Type | Description
--- | ---
NStack.ustring |

##### Remarks

If provided, the text will be drawn before any subviews are drawn.

The text will be drawn starting at the view origin (0, 0) and will be formatted according to the TextAlignment property. If the view's height is greater than 1, the text will word-wrap to additional lines if it does not fit horizontally. If the view's height is 1, the text will be clipped.

Set the HotKeySpecifier to enable hotkey support. To disable hotkey support set HotKeySpecifier to `(Rune)0xffff`.

#### TextAlignment

Gets or sets how the View's Text is aligned horizontally when drawn. Changing this property will redisplay the View.

##### Declaration

    public virtual TextAlignment TextAlignment { get; set; }

##### Property Value

Type | Description
--- | ---
TextAlignment | The text alignment.

#### TextDirection

Gets or sets the direction of the View's Text. Changing this property will redisplay the View.

##### Declaration

    public virtual TextDirection TextDirection { get; set; }

##### Property Value

Type | Description
--- | ---
TextDirection | The text alignment.

#### VerticalTextAlignment

Gets or sets how the View's Text is aligned verticaly when drawn. Changing this property will redisplay the View.

##### Declaration

    public virtual VerticalTextAlignment VerticalTextAlignment { get; set; }

##### Property Value

Type | Description
--- | ---
VerticalTextAlignment | The text alignment.

#### Visible

##### Declaration

    public override bool Visible { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

##### Overrides

Responder.Visible

#### WantContinuousButtonPressed

Gets or sets a value indicating whether this View want continuous button pressed event.

##### Declaration

    public virtual bool WantContinuousButtonPressed { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

#### WantMousePositionReports

Gets or sets a value indicating whether this View wants mouse position reports.

##### Declaration

    public virtual bool WantMousePositionReports { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean | `true` if want mouse position reports; otherwise, `false`.

#### Width

Gets or sets the width of the view. Only used the LayoutStyle is Computed.

##### Declaration

    public Dim Width { get; set; }

##### Property Value

Type | Description
--- | ---
Dim | The width.

##### Remarks

If LayoutStyle is Absolute changing this property has no effect and its value is indeterminate.

#### X

Gets or sets the X position for the view (the column). Only used the LayoutStyle is Computed.

##### Declaration

    public Pos X { get; set; }

##### Property Value

Type | Description
--- | ---
Pos | The X Position.

##### Remarks

If LayoutStyle is Absolute changing this property has no effect and its value is indeterminate.

#### Y

Gets or sets the Y position for the view (the row). Only used the LayoutStyle is Computed.

##### Declaration

    public Pos Y { get; set; }

##### Property Value

Type | Description
--- | ---
Pos | The y position (line).

##### Remarks

If LayoutStyle is Absolute changing this property has no effect and its value is indeterminate.

### Methods

#### Add(View)

Adds a subview (child) to this view.

##### Declaration

    public virtual void Add(View view)

##### Parameters

Type | Name | Description
--- | --- | ---
View | view |

##### Remarks

The Views that have been added to this view can be retrieved via the Subviews property. See also Remove(View) RemoveAll()

#### Add(View[])

Adds the specified views (children) to the view.

##### Declaration

    public void Add(params View[] views)

##### Parameters

Type | Name | Description
--- | --- | ---
View[] | views | Array of one or more views (can be optional parameter).

##### Remarks

The Views that have been added to this view can be retrieved via the Subviews property. See also Remove(View) RemoveAll()

#### AddCommand(Command, Func<Nullable<Boolean>>)

States that the given View supports a given `command` and what `f` to perform to make that command happen

If the `command` already has an implementation the `f` will replace the old one

##### Declaration

    protected void AddCommand(Command command, Func<bool?> f)

##### Parameters

Type | Name | Description
--- | --- | ---
Command | command | The command.
System.Func<System.Nullable<System.Boolean>> | f | The function.

#### AddKeyBinding(Key, Command)

Adds a new key combination that will trigger the given `command` (if supported by the View - see GetSupportedCommands())

If the key is already bound to a different Command it will be rebound to this one

##### Declaration

    public void AddKeyBinding(Key key, Command command)

##### Parameters

Type | Name | Description
--- | --- | ---
Key | key |
Command | command |

#### AddRune(Int32, Int32, Rune)

Displays the specified character in the specified column and row of the View.

##### Declaration

    public void AddRune(int col, int row, Rune ch)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | col | Column (view-relative).
System.Int32 | row | Row (view-relative).
System.Rune | ch | Ch.

#### BeginInit()

This derived from System.ComponentModel.ISupportInitializeNotification to allow notify all the views that are beginning initialized.

##### Declaration

    public void BeginInit()

#### BringSubviewForward(View)

Moves the subview backwards in the hierarchy, only one step

##### Declaration

    public void BringSubviewForward(View subview)

##### Parameters

Type | Name | Description
--- | --- | ---
View | subview | The subview to send backwards

##### Remarks

If you want to send the view all the way to the back use SendSubviewToBack.

#### BringSubviewToFront(View)

Brings the specified subview to the front so it is drawn on top of any other views.

##### Declaration

    public void BringSubviewToFront(View subview)

##### Parameters

Type | Name | Description
--- | --- | ---
View | subview | The subview to send to the front

##### Remarks

SendSubviewToBack(View).

#### Clear()

Clears the view region with the current color.

##### Declaration

    public void Clear()

##### Remarks

This clears the entire region used by this view.

#### Clear(Rect)

Clears the specified region with the current color.

##### Declaration

    public void Clear(Rect regionScreen)

##### Parameters

Type | Name | Description
--- | --- | ---
Rect | regionScreen | The screen-relative region to clear.

##### Remarks

#### ClearKeybinding(Command)

Removes all key bindings that trigger the given command. Views can have multiple different keys bound to the same command and this method will clear all of them.

##### Declaration

    public void ClearKeybinding(Command command)

##### Parameters

Type | Name | Description
--- | --- | ---
Command | command |

#### ClearKeybinding(Key)

Clears the existing keybinding (if any) for the given `key`

##### Declaration

    public void ClearKeybinding(Key key)

##### Parameters

Type | Name | Description
--- | --- | ---
Key | key |

#### ClearKeybindings()

Removes all bound keys from the View making including the default key combinations such as cursor navigation, scrolling etc

##### Declaration

    public void ClearKeybindings()

#### ClearLayoutNeeded()

Removes the Terminal.Gui.View.SetNeedsLayout setting on this view.

##### Declaration

    protected void ClearLayoutNeeded()

#### ClearNeedsDisplay()

Removes the SetNeedsDisplay() and the Terminal.Gui.View.ChildNeedsDisplay setting on this view.

##### Declaration

    protected void ClearNeedsDisplay()

#### ClipToBounds()

Sets the ConsoleDriver's clip region to the current View's Bounds.

##### Declaration

    public Rect ClipToBounds()

##### Returns

Type | Description
--- | ---
Rect | The existing driver's clip region, which can be then re-applied by setting `Driver.Clip` (Clip).

##### Remarks

Bounds is View-relative.

#### ContainsKeyBinding(Key)

Checks if key combination already exist.

##### Declaration

    public bool ContainsKeyBinding(Key key)

##### Parameters

Type | Name | Description
--- | --- | ---
Key | key | The key to check.

##### Returns

Type | Description
--- | ---
System.Boolean | `true` If the key already exist, `false`otherwise.

#### Dispose(Boolean)

##### Declaration

    protected override void Dispose(bool disposing)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Boolean | disposing |

##### Overrides

Responder.Dispose(Boolean)

#### DrawFrame(Rect, Int32, Boolean)

Draws a frame in the current view, clipped by the boundary of this view

##### Declaration

    public void DrawFrame(Rect region, int padding = 0, bool fill = false)

##### Parameters

Type | Name | Description
--- | --- | ---
Rect | region | View-relative region for the frame to be drawn.
System.Int32 | padding | The padding to add around the outside of the drawn frame.
System.Boolean | fill | If set to `true` it fill will the contents.

#### DrawHotString(ustring, Boolean, ColorScheme)

Utility function to draw strings that contains a hotkey using a ColorScheme and the "focused" state.

##### Declaration

    public void DrawHotString(ustring text, bool focused, ColorScheme scheme)

##### Parameters

Type | Name | Description
--- | --- | ---
NStack.ustring | text | String to display, the underscore before a letter flags the next letter as the hotkey.
System.Boolean | focused | If set to `true` this uses the focused colors from the color scheme, otherwise the regular ones.
ColorScheme | scheme | The color scheme to use.

#### DrawHotString(ustring, Attribute, Attribute)

Utility function to draw strings that contain a hotkey.

##### Declaration

    public void DrawHotString(ustring text, Attribute hotColor, Attribute normalColor)

##### Parameters

Type | Name | Description
--- | --- | ---
NStack.ustring | text | String to display, the hotkey specifier before a letter flags the next letter as the hotkey.
Attribute | hotColor | Hot color.
Attribute | normalColor | Normal color.

##### Remarks

The hotkey is any character following the hotkey specifier, which is the underscore ('_') character by default.

The hotkey specifier can be changed via HotKeySpecifier

#### EndInit()

This derived from System.ComponentModel.ISupportInitializeNotification to allow notify all the views that are ending initialized.

##### Declaration

    public void EndInit()

#### EnsureFocus()

Finds the first view in the hierarchy that wants to get the focus if nothing is currently focused, otherwise, it does nothing.

##### Declaration

    public void EnsureFocus()

#### FocusFirst()

Focuses the first focusable subview if one exists.

##### Declaration

    public void FocusFirst()

#### FocusLast()

Focuses the last focusable subview if one exists.

##### Declaration

    public void FocusLast()

#### FocusNext()

Focuses the next view.

##### Declaration

    public bool FocusNext()

##### Returns

Type | Description
--- | ---
System.Boolean | `true`, if next was focused, `false` otherwise.

#### FocusPrev()

Focuses the previous view.

##### Declaration

    public bool FocusPrev()

##### Returns

Type | Description
--- | ---
System.Boolean | `true`, if previous was focused, `false` otherwise.

#### GetCurrentHeight(out Int32)

Calculate the height based on the Height settings.

##### Declaration

    public bool GetCurrentHeight(out int currentHeight)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | currentHeight | The real current height.

##### Returns

Type | Description
--- | ---
System.Boolean | `true` if the height can be directly assigned, `false` otherwise.

#### GetCurrentWidth(out Int32)

Gets the current width based on the Width settings.

##### Declaration

    public bool GetCurrentWidth(out int currentWidth)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | currentWidth | The real current width.

##### Returns

Type | Description
--- | ---
System.Boolean | `true` if the width can be directly assigned, `false` otherwise.

#### GetKeyFromCommand(Command)

Gets the key used by a command.

##### Declaration

    public Key GetKeyFromCommand(Command command)

##### Parameters

Type | Name | Description
--- | --- | ---
Command | command | The command to search.

##### Returns

Type | Description
--- | ---
Key | The Key used by a Command

#### GetNormalColor()

Determines the current ColorScheme based on the Enabled value.

##### Declaration

    public Attribute GetNormalColor()

##### Returns

Type | Description
--- | ---
Attribute | Normal if Enabled is true or Disabled if Enabled is false

#### GetSupportedCommands()

Returns all commands that are supported by this View

##### Declaration

    public IEnumerable<Command> GetSupportedCommands()

##### Returns

Type | Description
--- | ---
System.Collections.Generic.IEnumerable<Command> |

#### GetTopSuperView()

Get the top superview of a given View.

##### Declaration

    public View GetTopSuperView()

##### Returns

Type | Description
--- | ---
View | The superview view.

#### InvokeKeybindings(KeyEvent)

Invokes any binding that is registered on this View and matches the `keyEvent`

##### Declaration

    protected bool? InvokeKeybindings(KeyEvent keyEvent)

##### Parameters

Type | Name | Description
--- | --- | ---
KeyEvent | keyEvent | The key event passed.

##### Returns

Type | Description
--- | ---
System.Nullable<System.Boolean> |

#### LayoutSubviews()

Invoked when a view starts executing or when the dimensions of the view have changed, for example in response to the container view or terminal resizing.

##### Declaration

    public virtual void LayoutSubviews()

##### Remarks

Calls Terminal.Gui.View.OnLayoutComplete(Terminal.Gui.View.LayoutEventArgs) (which raises the LayoutComplete event) before it returns.

#### Move(Int32, Int32, Boolean)

This moves the cursor to the specified column and row in the view.

##### Declaration

    public void Move(int col, int row, bool clipped = true)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | col | Col.
System.Int32 | row | Row.
System.Boolean | clipped | Whether to clip the result of the ViewToScreen method, if set to `true`, the col, row values are clamped to the screen (terminal) dimensions (0..TerminalDim-1).

#### OnAdded(View)

Method invoked when a subview is being added to this view.

##### Declaration

    public virtual void OnAdded(View view)

##### Parameters

Type | Name | Description
--- | --- | ---
View | view | The subview being added.

#### OnCanFocusChanged()

##### Declaration

    public override void OnCanFocusChanged()

##### Overrides

Responder.OnCanFocusChanged()

#### OnDrawContent(Rect)

Enables overrides to draw infinitely scrolled content and/or a background behind added controls.

##### Declaration

    public virtual void OnDrawContent(Rect viewport)

##### Parameters

Type | Name | Description
--- | --- | ---
Rect | viewport | The view-relative rectangle describing the currently visible viewport into the View

##### Remarks

This method will be called before any subviews added with Add(View) have been drawn.

#### OnDrawContentComplete(Rect)

Enables overrides after completed drawing infinitely scrolled content and/or a background behind removed controls.

##### Declaration

    public virtual void OnDrawContentComplete(Rect viewport)

##### Parameters

Type | Name | Description
--- | --- | ---
Rect | viewport | The view-relative rectangle describing the currently visible viewport into the View

##### Remarks

This method will be called after any subviews removed with Remove(View) have been completed drawing.

#### OnEnabledChanged()

##### Declaration

    public override void OnEnabledChanged()

##### Overrides

Responder.OnEnabledChanged()

#### OnEnter(View)

##### Declaration

    public override bool OnEnter(View view)

##### Parameters

Type | Name | Description
--- | --- | ---
View | view |

##### Returns

Type | Description
--- | ---
System.Boolean |

##### Overrides

Responder.OnEnter(View)

#### OnKeyDown(KeyEvent)

##### Declaration

    public override bool OnKeyDown(KeyEvent keyEvent)

##### Parameters

Type | Name | Description
--- | --- | ---
KeyEvent | keyEvent |

##### Returns

Type | Description
--- | ---
System.Boolean |

##### Overrides

Responder.OnKeyDown(KeyEvent)

#### OnKeyUp(KeyEvent)

##### Declaration

    public override bool OnKeyUp(KeyEvent keyEvent)

##### Parameters

Type | Name | Description
--- | --- | ---
KeyEvent | keyEvent |

##### Returns

Type | Description
--- | ---
System.Boolean |

##### Overrides

Responder.OnKeyUp(KeyEvent)

#### OnLeave(View)

##### Declaration

    public override bool OnLeave(View view)

##### Parameters

Type | Name | Description
--- | --- | ---
View | view |

##### Returns

Type | Description
--- | ---
System.Boolean |

##### Overrides

Responder.OnLeave(View)

#### OnMouseClick(View.MouseEventArgs)

Invokes the MouseClick event.

##### Declaration

    protected bool OnMouseClick(View.MouseEventArgs args)

##### Parameters

Type | Name | Description
--- | --- | ---
View.MouseEventArgs | args |

##### Returns

Type | Description
--- | ---
System.Boolean |

#### OnMouseEnter(MouseEvent)

##### Declaration

    public override bool OnMouseEnter(MouseEvent mouseEvent)

##### Parameters

Type | Name | Description
--- | --- | ---
MouseEvent | mouseEvent |

##### Returns

Type | Description
--- | ---
System.Boolean |

##### Overrides

Responder.OnMouseEnter(MouseEvent)

#### OnMouseEvent(MouseEvent)

Method invoked when a mouse event is generated

##### Declaration

    public virtual bool OnMouseEvent(MouseEvent mouseEvent)

##### Parameters

Type | Name | Description
--- | --- | ---
MouseEvent | mouseEvent |

##### Returns

Type | Description
--- | ---
System.Boolean | `true`, if the event was handled, `false` otherwise.

#### OnMouseLeave(MouseEvent)

##### Declaration

    public override bool OnMouseLeave(MouseEvent mouseEvent)

##### Parameters

Type | Name | Description
--- | --- | ---
MouseEvent | mouseEvent |

##### Returns

Type | Description
--- | ---
System.Boolean |

##### Overrides

Responder.OnMouseLeave(MouseEvent)

#### OnRemoved(View)

Method invoked when a subview is being removed from this view.

##### Declaration

    public virtual void OnRemoved(View view)

##### Parameters

Type | Name | Description
--- | --- | ---
View | view | The subview being removed.

#### OnVisibleChanged()

##### Declaration

    public override void OnVisibleChanged()

##### Overrides

Responder.OnVisibleChanged()

#### PositionCursor()

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

##### Declaration

    public virtual void PositionCursor()

#### ProcessColdKey(KeyEvent)

##### Declaration

    public override bool ProcessColdKey(KeyEvent keyEvent)

##### Parameters

Type | Name | Description
--- | --- | ---
KeyEvent | keyEvent |

##### Returns

Type | Description
--- | ---
System.Boolean |

##### Overrides

Responder.ProcessColdKey(KeyEvent)

#### ProcessHotKey(KeyEvent)

##### Declaration

    public override bool ProcessHotKey(KeyEvent keyEvent)

##### Parameters

Type | Name | Description
--- | --- | ---
KeyEvent | keyEvent |

##### Returns

Type | Description
--- | ---
System.Boolean |

##### Overrides

Responder.ProcessHotKey(KeyEvent)

#### ProcessKey(KeyEvent)

##### Declaration

    public override bool ProcessKey(KeyEvent keyEvent)

##### Parameters

Type | Name | Description
--- | --- | ---
KeyEvent | keyEvent |

##### Returns

Type | Description
--- | ---
System.Boolean |

##### Overrides

Responder.ProcessKey(KeyEvent)

#### Redraw(Rect)

Redraws this view and its subviews; only redraws the views that have been flagged for a re-display.

##### Declaration

    public virtual void Redraw(Rect bounds)

##### Parameters

Type | Name | Description
--- | --- | ---
Rect | bounds | The bounds (view-relative region) to redraw.

##### Remarks

Always use Bounds (view-relative) when calling Redraw(Rect), NOT Frame (superview-relative).

Views should set the color that they want to use on entry, as otherwise this will inherit the last color that was set globally on the driver.

Overrides of Redraw(Rect) must ensure they do not set `Driver.Clip` to a clip region larger than the `region` parameter.

#### Remove(View)

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

##### Declaration

    public virtual void Remove(View view)

##### Parameters

Type | Name | Description
--- | --- | ---
View | view |

##### Remarks

#### RemoveAll()

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

##### Declaration

    public virtual void RemoveAll()

#### ReplaceKeyBinding(Key, Key)

Replaces a key combination already bound to Command.

##### Declaration

    protected void ReplaceKeyBinding(Key fromKey, Key toKey)

##### Parameters

Type | Name | Description
--- | --- | ---
Key | fromKey | The key to be replaced.
Key | toKey | The new key to be used.

#### ScreenToView(Int32, Int32)

Converts a point from screen-relative coordinates to view-relative coordinates.

##### Declaration

    public Point ScreenToView(int x, int y)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | x | X screen-coordinate point.
System.Int32 | y | Y screen-coordinate point.

##### Returns

Type | Description
--- | ---
Point | The mapped point.

#### SendSubviewBackwards(View)

Moves the subview backwards in the hierarchy, only one step

##### Declaration

    public void SendSubviewBackwards(View subview)

##### Parameters

Type | Name | Description
--- | --- | ---
View | subview | The subview to send backwards

##### Remarks

If you want to send the view all the way to the back use SendSubviewToBack.

#### SendSubviewToBack(View)

Sends the specified subview to the front so it is the first view drawn

##### Declaration

    public void SendSubviewToBack(View subview)

##### Parameters

Type | Name | Description
--- | --- | ---
View | subview | The subview to send to the front

##### Remarks

BringSubviewToFront(View).

#### SetChildNeedsDisplay()

Indicates that any child views (in the Subviews list) need to be repainted.

##### Declaration

    public void SetChildNeedsDisplay()

#### SetClip(Rect)

Sets the clip region to the specified view-relative region.

##### Declaration

    public Rect SetClip(Rect region)

##### Parameters

Type | Name | Description
--- | --- | ---
Rect | region | View-relative clip region.

##### Returns

Type | Description
--- | ---
Rect | The previous screen-relative clip region.

#### SetFocus()

Causes the specified view and the entire parent hierarchy to have the focused order updated.

##### Declaration

    public void SetFocus()

#### SetHeight(Int32, out Int32)

Calculate the height based on the Height settings.

##### Declaration

    public bool SetHeight(int desiredHeight, out int resultHeight)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | desiredHeight | The desired height.
System.Int32 | resultHeight | The real result height.

##### Returns

Type | Description
--- | ---
System.Boolean | `true` if the height can be directly assigned, `false` otherwise.

#### SetNeedsDisplay()

Sets a flag indicating this view needs to be redisplayed because its state has changed.

##### Declaration

    public void SetNeedsDisplay()

#### SetNeedsDisplay(Rect)

Flags the view-relative region on this View as needing to be repainted.

##### Declaration

    public void SetNeedsDisplay(Rect region)

##### Parameters

Type | Name | Description
--- | --- | ---
Rect | region | The view-relative region that must be flagged for repaint.

#### SetWidth(Int32, out Int32)

Calculate the width based on the Width settings.

##### Declaration

    public bool SetWidth(int desiredWidth, out int resultWidth)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | desiredWidth | The desired width.
System.Int32 | resultWidth | The real result width.

##### Returns

Type | Description
--- | ---
System.Boolean | `true` if the width can be directly assigned, `false` otherwise.

#### ToString()

Pretty prints the View

##### Declaration

    public override string ToString()

##### Returns

Type | Description
--- | ---
System.String |

##### Overrides

System.Object.ToString()

### Events

#### Added

Event fired when a subview is being added to this view.

##### Declaration

    public event Action<View> Added

##### Event Type

Type | Description
--- | ---
System.Action<View> |

#### CanFocusChanged

Event fired when the CanFocus value is being changed.

##### Declaration

    public event Action CanFocusChanged

##### Event Type

Type | Description
--- | ---
System.Action |

#### DrawContent

Event invoked when the content area of the View is to be drawn.

##### Declaration

    public event Action<Rect> DrawContent

##### Event Type

Type | Description
--- | ---
System.Action<Rect> |

##### Remarks

Will be invoked before any subviews added with Add(View) have been drawn.

Rect provides the view-relative rectangle describing the currently visible viewport into the View.

#### DrawContentComplete

Event invoked when the content area of the View is completed drawing.

##### Declaration

    public event Action<Rect> DrawContentComplete

##### Event Type

Type | Description
--- | ---
System.Action<Rect> |

##### Remarks

Will be invoked after any subviews removed with Remove(View) have been completed drawing.

Rect provides the view-relative rectangle describing the currently visible viewport into the View.

#### EnabledChanged

Event fired when the Enabled value is being changed.

##### Declaration

    public event Action EnabledChanged

##### Event Type

Type | Description
--- | ---
System.Action |

#### Enter

Event fired when the view gets focus.

##### Declaration

    public event Action<View.FocusEventArgs> Enter

##### Event Type

Type | Description
--- | ---
System.Action<View.FocusEventArgs> |

#### HotKeyChanged

Event invoked when the HotKey is changed.

##### Declaration

    public event Action<Key> HotKeyChanged

##### Event Type

Type | Description
--- | ---
System.Action<Key> |

#### Initialized

Event called only once when the View is being initialized for the first time. Allows configurations and assignments to be performed before the View being shown. This derived from System.ComponentModel.ISupportInitializeNotification to allow notify all the views that are being initialized.

##### Declaration

    public event EventHandler Initialized

##### Event Type

Type | Description
--- | ---
System.EventHandler |

#### KeyDown

Invoked when a key is pressed

##### Declaration

    public event Action<View.KeyEventEventArgs> KeyDown

##### Event Type

Type | Description
--- | ---
System.Action<View.KeyEventEventArgs> |

#### KeyPress

Invoked when a character key is pressed and occurs after the key up event.

##### Declaration

    public event Action<View.KeyEventEventArgs> KeyPress

##### Event Type

Type | Description
--- | ---
System.Action<View.KeyEventEventArgs> |

#### KeyUp

Invoked when a key is released

##### Declaration

    public event Action<View.KeyEventEventArgs> KeyUp

##### Event Type

Type | Description
--- | ---
System.Action<View.KeyEventEventArgs> |

#### LayoutComplete

Fired after the Views's LayoutSubviews() method has completed.

##### Declaration

    public event Action<View.LayoutEventArgs> LayoutComplete

##### Event Type

Type | Description
--- | ---
System.Action<View.LayoutEventArgs> |

##### Remarks

Subscribe to this event to perform tasks when the View has been resized or the layout has otherwise changed.

#### LayoutStarted

Fired after the Views's LayoutSubviews() method has completed.

##### Declaration

    public event Action<View.LayoutEventArgs> LayoutStarted

##### Event Type

Type | Description
--- | ---
System.Action<View.LayoutEventArgs> |

##### Remarks

Subscribe to this event to perform tasks when the View has been resized or the layout has otherwise changed.

#### Leave

Event fired when the view looses focus.

##### Declaration

    public event Action<View.FocusEventArgs> Leave

##### Event Type

Type | Description
--- | ---
System.Action<View.FocusEventArgs> |

#### MouseClick

Event fired when a mouse event is generated.

##### Declaration

    public event Action<View.MouseEventArgs> MouseClick

##### Event Type

Type | Description
--- | ---
System.Action<View.MouseEventArgs> |

#### MouseEnter

Event fired when the view receives the mouse event for the first time.

##### Declaration

    public event Action<View.MouseEventArgs> MouseEnter

##### Event Type

Type | Description
--- | ---
System.Action<View.MouseEventArgs> |

#### MouseLeave

Event fired when the view receives a mouse event for the last time.

##### Declaration

    public event Action<View.MouseEventArgs> MouseLeave

##### Event Type

Type | Description
--- | ---
System.Action<View.MouseEventArgs> |

#### Removed

Event fired when a subview is being removed from this view.

##### Declaration

    public event Action<View> Removed

##### Event Type

Type | Description
--- | ---
System.Action<View> |

#### VisibleChanged

Event fired when the Visible value is being changed.

##### Declaration

    public event Action VisibleChanged

##### Event Type

Type | Description
--- | ---
System.Action |

### Implements

System.IDisposable
System.ComponentModel.ISupportInitializeNotification
System.ComponentModel.ISupportInitialize