From 46d611e53e86a85eab2178734539bc4e74969d54 Mon Sep 17 00:00:00 2001 From: flustix Date: Sun, 14 Apr 2024 21:41:04 +0200 Subject: [PATCH] Add tabbing support to setup metadata --- .../Edit/Tabs/Setup/Entries/SetupTextBox.cs | 18 +++++++++++++++++- fluXis.Game/Screens/Edit/Tabs/SetupTab.cs | 11 +++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/fluXis.Game/Screens/Edit/Tabs/Setup/Entries/SetupTextBox.cs b/fluXis.Game/Screens/Edit/Tabs/Setup/Entries/SetupTextBox.cs index ff0de883..676ecd25 100644 --- a/fluXis.Game/Screens/Edit/Tabs/Setup/Entries/SetupTextBox.cs +++ b/fluXis.Game/Screens/Edit/Tabs/Setup/Entries/SetupTextBox.cs @@ -3,17 +3,27 @@ using fluXis.Game.Graphics.UserInterface.Color; using fluXis.Game.Graphics.UserInterface.Text; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Input.Events; namespace fluXis.Game.Screens.Edit.Tabs.Setup.Entries; -public partial class SetupTextBox : SetupEntry +public partial class SetupTextBox : SetupEntry, ITabbableContainer { + public bool CanBeTabbedTo => true; + public override bool AcceptsFocus => true; + protected override float ContentSpacing => -3; public string Default { get; init; } = string.Empty; public string Placeholder { get; init; } = string.Empty; public Action OnChange { get; init; } = _ => { }; + public CompositeDrawable TabbableContentContainer + { + set => textBox.TabbableContentContainer = value; + } + private FluXisTextBox textBox; public SetupTextBox(string title) @@ -36,4 +46,10 @@ protected override Drawable CreateContent() OnTextChanged = () => OnChange.Invoke(textBox.Text) }; } + + protected override void OnFocus(FocusEvent e) + { + // redirect focus to the textbox + GetContainingInputManager().ChangeFocus(textBox); + } } diff --git a/fluXis.Game/Screens/Edit/Tabs/SetupTab.cs b/fluXis.Game/Screens/Edit/Tabs/SetupTab.cs index 23347fef..fb57fac2 100644 --- a/fluXis.Game/Screens/Edit/Tabs/SetupTab.cs +++ b/fluXis.Game/Screens/Edit/Tabs/SetupTab.cs @@ -1,9 +1,11 @@ +using System.Linq; using fluXis.Game.Graphics.Containers; using fluXis.Game.Graphics.Sprites; using fluXis.Game.Graphics.UserInterface.Color; using fluXis.Game.Screens.Edit.Tabs.Setup; using fluXis.Game.Screens.Edit.Tabs.Setup.Entries; using osu.Framework.Allocation; +using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -17,6 +19,8 @@ public partial class SetupTab : EditorTab public override IconUsage Icon => FontAwesome6.Solid.ScrewdriverWrench; public override string TabName => "Setup"; + private SetupSection metadata; + [BackgroundDependencyLoader] private void load(EditorMap map) { @@ -71,7 +75,7 @@ private void load(EditorMap map) Spacing = new Vector2(30), Children = new Drawable[] { - new SetupSection("Metadata") + metadata = new SetupSection("Metadata") { Entries = new Drawable[] { @@ -110,7 +114,7 @@ private void load(EditorMap map) Default = map.MapInfo.Metadata.Tags, Placeholder = "No Tags", OnChange = value => map.MapInfo.Metadata.Tags = map.RealmMap.Metadata.Tags = value - }, + } } }, new SetupSection("Colors") @@ -206,5 +210,8 @@ private void load(EditorMap map) } } }; + + // tabbing support + metadata.OfType().ForEach(textBox => textBox.TabbableContentContainer = metadata); } }