PowerArgs.Cli.ConsoleControl.FireFocused C# (CSharp) Method

FireFocused() private method

private FireFocused ( bool focused ) : void
focused bool
return void
        internal void FireFocused(bool focused)
        {
            if (focused) Focused.Fire();
            else Unfocused.Fire();
        }

Usage Example

Example #1
0
        /// <summary>
        /// Tries to set focus on the given control.
        /// </summary>
        /// <param name="newFocusControl">the control to focus.  </param>
        /// <returns>True if the focus was set or if it was already set, false if the control cannot be focused</returns>
        public bool TrySetFocus(ConsoleControl newFocusControl)
        {
            var index = focusStack.Peek().Controls.IndexOf(newFocusControl);

            if (index < 0)
            {
                throw new InvalidOperationException("The given control is not in the control tree");
            }

            if (newFocusControl.CanFocus == false)
            {
                return(false);
            }
            else if (newFocusControl == FocusedControl)
            {
                return(true);
            }
            else
            {
                if (FocusedControl != null)
                {
                    ClearFocus();
                }

                newFocusControl.HasFocus = true;
                FocusedControl           = newFocusControl;
                focusStack.Peek().FocusIndex = index;

                if (FocusedControl != null)
                {
                    FocusedControl.FireFocused(true);
                }
                return(true);
            }
        }
All Usage Examples Of PowerArgs.Cli.ConsoleControl::FireFocused