Table of Contents

Property HasFocus

Namespace
Terminal.Gui
Assembly
Terminal.Gui.dll

HasFocus

Gets or sets whether this view has focus.

public bool HasFocus { get; set; }

Property Value

bool

Remarks

See the View Navigation Deep Dive for more information: https://gui-cs.github.io/Terminal.GuiV2Docs/docs/navigation.html

Only Views that are visible, enabled, and have CanFocus set to true are focusable. If these conditions are not met when this property is set to trueHasFocus will not change.

Setting this property causes the OnHasFocusChanging(bool, bool, View?, View?) and OnHasFocusChanged(bool, View?, View?) virtual methods (and HasFocusChanging and HasFocusChanged events to be raised). If the event is cancelled, HasFocus will not be changed.

Setting this property to true will recursively set HasFocus to true for all SuperViews up the hierarchy.

Setting this property to true will cause the subview furthest down the hierarchy that is focusable to also gain focus (as long as TabStop

Setting this property to false will cause AdvanceFocus(NavigationDirection, TabBehavior?) to set the focus on the next view to be focused.