mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 15:27:30 +08:00
Null-propagate all calls to GetContainingFocusManager()
This commit is contained in:
parent
7f08008059
commit
8a4ae5d23d
@ -58,7 +58,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
editorInfo.Selected.ValueChanged += selection =>
|
||||
{
|
||||
// ensure any ongoing edits are committed out to the *current* selection before changing to a new one.
|
||||
GetContainingFocusManager().TriggerFocusContention(null);
|
||||
GetContainingFocusManager()?.TriggerFocusContention(null);
|
||||
|
||||
// Required to avoid cyclic failure in BindableWithCurrent (TriggerChange called during the Current_Set process).
|
||||
// Arguable a framework issue but since we haven't hit it anywhere else a local workaround seems best.
|
||||
|
@ -31,7 +31,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
if (!allowImmediateFocus)
|
||||
return;
|
||||
|
||||
Scheduler.Add(() => GetContainingFocusManager().ChangeFocus(this));
|
||||
Scheduler.Add(() => GetContainingFocusManager()?.ChangeFocus(this));
|
||||
}
|
||||
|
||||
public new void KillFocus() => base.KillFocus();
|
||||
|
@ -59,7 +59,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
protected override void OnFocus(FocusEvent e)
|
||||
{
|
||||
base.OnFocus(e);
|
||||
GetContainingFocusManager().ChangeFocus(Component);
|
||||
GetContainingFocusManager()?.ChangeFocus(Component);
|
||||
}
|
||||
|
||||
protected override OsuTextBox CreateComponent() => CreateTextBox().With(t =>
|
||||
|
@ -85,7 +85,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
Current.BindValueChanged(updateTextBoxFromSlider, true);
|
||||
}
|
||||
|
||||
public bool TakeFocus() => GetContainingFocusManager().ChangeFocus(textBox);
|
||||
public bool TakeFocus() => GetContainingFocusManager()?.ChangeFocus(textBox) == true;
|
||||
|
||||
public bool SelectAll() => textBox.SelectAll();
|
||||
|
||||
|
@ -243,7 +243,7 @@ namespace osu.Game.Overlays.AccountCreation
|
||||
|
||||
if (nextTextBox != null)
|
||||
{
|
||||
Schedule(() => GetContainingFocusManager().ChangeFocus(nextTextBox));
|
||||
Schedule(() => GetContainingFocusManager()?.ChangeFocus(nextTextBox));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ namespace osu.Game.Overlays.Comments
|
||||
base.LoadComplete();
|
||||
|
||||
if (!TextBox.ReadOnly)
|
||||
GetContainingFocusManager().ChangeFocus(TextBox);
|
||||
GetContainingFocusManager()?.ChangeFocus(TextBox);
|
||||
}
|
||||
|
||||
protected override void OnCommit(string text)
|
||||
|
@ -150,7 +150,7 @@ namespace osu.Game.Overlays.Login
|
||||
|
||||
protected override void OnFocus(FocusEvent e)
|
||||
{
|
||||
Schedule(() => { GetContainingFocusManager().ChangeFocus(string.IsNullOrEmpty(username.Text) ? username : password); });
|
||||
Schedule(() => { GetContainingFocusManager()?.ChangeFocus(string.IsNullOrEmpty(username.Text) ? username : password); });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ namespace osu.Game.Overlays.Login
|
||||
|
||||
protected override void OnFocus(FocusEvent e)
|
||||
{
|
||||
if (form != null) GetContainingFocusManager().ChangeFocus(form);
|
||||
if (form != null) GetContainingFocusManager()?.ChangeFocus(form);
|
||||
base.OnFocus(e);
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ namespace osu.Game.Overlays.Login
|
||||
|
||||
protected override void OnFocus(FocusEvent e)
|
||||
{
|
||||
Schedule(() => { GetContainingFocusManager().ChangeFocus(codeTextBox); });
|
||||
Schedule(() => { GetContainingFocusManager()?.ChangeFocus(codeTextBox); });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ namespace osu.Game.Overlays
|
||||
this.FadeIn(transition_time, Easing.OutQuint);
|
||||
FadeEdgeEffectTo(WaveContainer.SHADOW_OPACITY, WaveContainer.APPEAR_DURATION, Easing.Out);
|
||||
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager().ChangeFocus(panel));
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager()?.ChangeFocus(panel));
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
|
@ -89,7 +89,7 @@ namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager().ChangeFocus(nameTextBox));
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager()?.ChangeFocus(nameTextBox));
|
||||
|
||||
nameTextBox.Current.BindValueChanged(s =>
|
||||
{
|
||||
|
@ -136,7 +136,7 @@ namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager().ChangeFocus(nameTextBox));
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager()?.ChangeFocus(nameTextBox));
|
||||
}
|
||||
|
||||
public override bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
||||
|
@ -949,7 +949,7 @@ namespace osu.Game.Overlays.Mods
|
||||
RequestScroll?.Invoke(this);
|
||||
|
||||
// Killing focus is done here because it's the only feasible place on ModSelectOverlay you can click on without triggering any action.
|
||||
Scheduler.Add(() => GetContainingFocusManager().ChangeFocus(null));
|
||||
Scheduler.Add(() => GetContainingFocusManager()?.ChangeFocus(null));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -465,7 +465,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
}
|
||||
|
||||
if (HasFocus)
|
||||
GetContainingFocusManager().ChangeFocus(null);
|
||||
GetContainingFocusManager()?.ChangeFocus(null);
|
||||
|
||||
cancelAndClearButtons.FadeOut(300, Easing.OutQuint);
|
||||
cancelAndClearButtons.BypassAutoSizeAxes |= Axes.Y;
|
||||
|
@ -106,7 +106,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
{
|
||||
var next = Children.SkipWhile(c => c != sender).Skip(1).FirstOrDefault();
|
||||
if (next != null)
|
||||
GetContainingFocusManager().ChangeFocus(next);
|
||||
GetContainingFocusManager()?.ChangeFocus(next);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
searchTextBox.HoldFocus = false;
|
||||
if (searchTextBox.HasFocus)
|
||||
GetContainingFocusManager().ChangeFocus(null);
|
||||
GetContainingFocusManager()?.ChangeFocus(null);
|
||||
}
|
||||
|
||||
public override bool AcceptsFocus => true;
|
||||
|
@ -580,7 +580,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
GetContainingFocusManager().ChangeFocus(this);
|
||||
GetContainingFocusManager()?.ChangeFocus(this);
|
||||
SelectAll();
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager().ChangeFocus(sliderVelocitySlider));
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager()?.ChangeFocus(sliderVelocitySlider));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
OnFocused?.Invoke();
|
||||
base.OnFocus(e);
|
||||
|
||||
GetContainingFocusManager().TriggerFocusContention(this);
|
||||
GetContainingFocusManager()?.TriggerFocusContention(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
base.LoadComplete();
|
||||
|
||||
if (string.IsNullOrEmpty(ArtistTextBox.Current.Value))
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager().ChangeFocus(ArtistTextBox));
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager()?.ChangeFocus(ArtistTextBox));
|
||||
|
||||
ArtistTextBox.Current.BindValueChanged(artist => transferIfRomanised(artist.NewValue, RomanisedArtistTextBox));
|
||||
TitleTextBox.Current.BindValueChanged(title => transferIfRomanised(title.NewValue, RomanisedTitleTextBox));
|
||||
|
@ -126,7 +126,7 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
protected override void OnFocus(FocusEvent e)
|
||||
{
|
||||
base.OnFocus(e);
|
||||
GetContainingFocusManager().ChangeFocus(textBox);
|
||||
GetContainingFocusManager()?.ChangeFocus(textBox);
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
|
@ -248,21 +248,21 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager().ChangeFocus(passwordTextBox));
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager()?.ChangeFocus(passwordTextBox));
|
||||
passwordTextBox.OnCommit += (_, _) => performJoin();
|
||||
}
|
||||
|
||||
private void performJoin()
|
||||
{
|
||||
lounge?.Join(room, passwordTextBox.Text, null, joinFailed);
|
||||
GetContainingFocusManager().TriggerFocusContention(passwordTextBox);
|
||||
GetContainingFocusManager()?.TriggerFocusContention(passwordTextBox);
|
||||
}
|
||||
|
||||
private void joinFailed(string error) => Schedule(() =>
|
||||
{
|
||||
passwordTextBox.Text = string.Empty;
|
||||
|
||||
GetContainingFocusManager().ChangeFocus(passwordTextBox);
|
||||
GetContainingFocusManager()?.ChangeFocus(passwordTextBox);
|
||||
|
||||
errorText.Text = error;
|
||||
errorText
|
||||
|
@ -245,7 +245,7 @@ namespace osu.Game.Screens.Select
|
||||
searchTextBox.ReadOnly = true;
|
||||
searchTextBox.HoldFocus = false;
|
||||
if (searchTextBox.HasFocus)
|
||||
GetContainingFocusManager().ChangeFocus(searchTextBox);
|
||||
GetContainingFocusManager()?.ChangeFocus(searchTextBox);
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
|
@ -81,7 +81,7 @@ namespace osu.Game.Screens.SelectV2.Footer
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager().ChangeFocus(this));
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager()?.ChangeFocus(this));
|
||||
|
||||
beatmap.BindValueChanged(_ => Hide());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user