C# Class PowerArgs.Cli.FocusManager

A class that manages the focus of a CLI application
Inheritance: ObservableObject
Show file Open project: adamabdelhamed/PowerArgs Class Usage Examples

Public Methods

Method Description
Add ( ConsoleControl c ) : void

Adds the current control to the current focus context

ClearFocus ( ) : void

Clears the focus, but preserves the focus index

FocusManager ( ) : System

Initializes the focus manager

Pop ( ) : void

Pops the current focus context. This should be called if you've implemented a modal dialog like experience and your dialog has just closed. Pop() will automatically restore focus on the previous context.

Push ( ) : void

Pushes a new focus context onto the stack. This is useful, for example, when a dialog appears above all other controls and you want to limit focus to the dialog to acheive a modal affect. You must remember to call pop when your context ends.

Remove ( ConsoleControl c ) : void

Removes the control from all focus contexts

TryMoveFocus ( bool forward = true ) : bool

Tries to move the focus forward or backwards

TryRestoreFocus ( ) : bool

Tries to restore the focus on the given context

TrySetFocus ( ConsoleControl newFocusControl ) : bool

Tries to set focus on the given control.

Private Methods

Method Description
CycleFocusIndex ( bool forward ) : bool

Method Details

Add() public method

Adds the current control to the current focus context
public Add ( ConsoleControl c ) : void
c ConsoleControl The control to add
return void

ClearFocus() public method

Clears the focus, but preserves the focus index
public ClearFocus ( ) : void
return void

FocusManager() public method

Initializes the focus manager
public FocusManager ( ) : System
return System

Pop() public method

Pops the current focus context. This should be called if you've implemented a modal dialog like experience and your dialog has just closed. Pop() will automatically restore focus on the previous context.
public Pop ( ) : void
return void

Push() public method

Pushes a new focus context onto the stack. This is useful, for example, when a dialog appears above all other controls and you want to limit focus to the dialog to acheive a modal affect. You must remember to call pop when your context ends.
public Push ( ) : void
return void

Remove() public method

Removes the control from all focus contexts
public Remove ( ConsoleControl c ) : void
c ConsoleControl The control to remove
return void

TryMoveFocus() public method

Tries to move the focus forward or backwards
public TryMoveFocus ( bool forward = true ) : bool
forward bool If true then the manager will try to move forwards, otherwise backwards
return bool

TryRestoreFocus() public method

Tries to restore the focus on the given context
public TryRestoreFocus ( ) : bool
return bool

TrySetFocus() public method

Tries to set focus on the given control.
public TrySetFocus ( ConsoleControl newFocusControl ) : bool
newFocusControl ConsoleControl the control to focus.
return bool