A game framework written with osu! in mind.
at master 26 lines 843 B view raw
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. 2// See the LICENCE file in the repository root for full licence text. 3 4namespace osu.Framework.Graphics.Containers 5{ 6 /// <summary> 7 /// An overlay container that eagerly holds keyboard focus. 8 /// </summary> 9 public abstract class FocusedOverlayContainer : OverlayContainer 10 { 11 public override bool RequestsFocus => State.Value == Visibility.Visible; 12 13 public override bool AcceptsFocus => State.Value == Visibility.Visible; 14 15 protected override void PopIn() 16 { 17 Schedule(() => GetContainingInputManager().TriggerFocusContention(this)); 18 } 19 20 protected override void PopOut() 21 { 22 if (HasFocus) 23 GetContainingInputManager().ChangeFocus(null); 24 } 25 } 26}