MonoGameUi.Control.SetFocus C# (CSharp) Method

SetFocus() private method

Setzt den Fokus auf das angegebene Control für den kompletten Visual Tree ab diesem Control abwärts.
private SetFocus ( Control control ) : void
control Control
return void
        internal void SetFocus(Control control)
        {
            // Rekursiver Aufruf
            foreach (var child in Children.InZOrder())
                child.SetFocus(control);

            bool hit = (control == this);
            if (focused != hit)
            {
                EventArgs args = new EventArgs();
                if (hit)
                {
                    // Unsichtbare und nicht fokusierbare Elemente ignorieren
                    if (!Visible || !CanFocus || !Enabled)
                        return;

                    focused = true;

                    // Fokus gerade erhalten
                    OnGotFocus(args);
                    if (GotFocus != null)
                        GotFocus(this, args);
                }
                else
                {
                    focused = false;

                    // Fokus gerade verloren
                    OnLostFocus(args);
                    if (LostFocus != null)
                        LostFocus(this, args);
                }

                InvalidateDrawing();
            }
        }