private GLBaseControl mousedowninitialcontrol = null; // track where mouse down occurred

        private bool SetFocus(GLBaseControl newfocus)         // null to clear focus, true if focus taken
        {
            if (newfocus == currentfocus)                     // no action if the same
            {
                return(true);
            }

            if (newfocus != null)
            {
                if (newfocus.GiveFocusToParent && newfocus.Parent != null && newfocus.Parent.RejectFocus == false)
                {
                    newfocus = newfocus.Parent; // see if we want to give it to parent
                }
                if (newfocus.RejectFocus)       // if reject focus change when clicked, abort, do not change focus
                {
                    return(false);
                }

                if (!newfocus.Enabled || !newfocus.Focusable)       // if its not enabled or not focusable, change to no focus
                {
                    //System.Diagnostics.Debug.WriteLine("Focus target not enabled/focusable " + newfocus.Name);
                    newfocus = null;
                }
            }

            GLBaseControl oldfocus = currentfocus;

            OnGlobalFocusChanged(oldfocus, newfocus);

            //            System.Diagnostics.Debug.WriteLine("Focus changed from '{0}' to '{1}' {2}", oldfocus?.Name, newfocus?.Name, Environment.StackTrace);

            if (currentfocus != null)           // if we have a focus, inform losing it, and cancel it
            {
                currentfocus.OnFocusChanged(FocusEvent.Deactive, newfocus);

                for (var c = currentfocus.Parent; c != null; c = c.Parent)      // inform change up and including the GLForm
                {
                    c.OnFocusChanged(FocusEvent.ChildDeactive, newfocus);
                    if (c is GLForm)
                    {
                        break;
                    }
                }

                currentfocus = null;
            }

            if (newfocus != null)               // if we have a new focus, set and tell it
            {
                currentfocus = newfocus;

                currentfocus.OnFocusChanged(FocusEvent.Focused, oldfocus);

                for (var c = currentfocus.Parent; c != null; c = c.Parent)      // inform change up and including the GLForm
                {
                    c.OnFocusChanged(FocusEvent.ChildFocused, currentfocus);
                    if (c is GLForm)
                    {
                        break;
                    }
                }
            }

            return(true);
        }