FireFocused() private method

private FireFocused ( bool focused ) : void
focused bool
return void
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);
            }
        }
Example #2
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)
            {
                return(false);
            }

            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);
            }
        }
Example #3
0
        public void SetFocus(ConsoleControl newFocusControl)
        {
            var index = focusableControls.IndexOf(newFocusControl);

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

            if (newFocusControl != focusedControl)
            {
                if (focusedControl != null)
                {
                    focusedControl.HasFocus = false;
                    focusedControl.FireFocused(false);
                }

                focusedControl          = newFocusControl;
                focusedControl.HasFocus = true;
                focusIndex = index;

                if (focusedControl != null)
                {
                    focusedControl.FireFocused(true);
                }
            }
        }
Example #4
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;
            }
        }
Example #5
0
        public void SetFocus(ConsoleControl newFocusControl)
        {
            var index = focusableControls.IndexOf(newFocusControl);
            if (index < 0) throw new InvalidOperationException("The given control is not in the control tree");

            if (newFocusControl != focusedControl)
            {
                if (focusedControl != null)
                {
                    focusedControl.HasFocus = false;
                    focusedControl.FireFocused(false);
                }

                focusedControl = newFocusControl;
                focusedControl.HasFocus = true;
                focusIndex = index;

                if (focusedControl != null) focusedControl.FireFocused(true);
            }
        }