Skip to content

Commit 1cc79c1

Browse files
cornerloanLifeHckr
andauthored
Fixed menu focusing bug (#164)
* fixed menu losing focus with multiple inputs * fixed same issue for inventory screen * Simplify focus fix logic Co-Authored-By: Connor Lowe <74088480+cornerloan@users.noreply.github.com> --------- Co-authored-by: LifeHckr <jarodthereal@gmail.com>
1 parent a7451e9 commit 1cc79c1

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

Scenes/UI/Remapping/ControlSettings.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ public override void _Process(double delta)
151151
{
152152
if (_remapPopup.Visible)
153153
_remapLabel.Text = ((int)_remapTimer.TimeLeft + 1).ToString();
154+
NoNullFocus();
154155
}
155156

156157
public void ResumeFocus()
@@ -177,6 +178,14 @@ public void ReturnToPrev()
177178
QueueFree();
178179
}
179180

181+
private void NoNullFocus()
182+
{
183+
var focusedNode = GetViewport().GuiGetFocusOwner();
184+
if (focusedNode != null)
185+
return;
186+
_remapTabs.GetTabBar().GrabFocus();
187+
}
188+
180189
#endregion
181190

182191
/// <summary>

Scenes/UI/Scripts/Inventory.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ private void AddDisplayButtons(IDisplayable[] displayables, Node parentNode)
4343
}
4444
}
4545

46+
public override void _Process(double delta)
47+
{
48+
NoNullFocus();
49+
}
50+
4651
public override void _Input(InputEvent @event)
4752
{
4853
if (!GetWindow().HasFocus())
@@ -101,6 +106,15 @@ public void ReturnToPrev()
101106
QueueFree();
102107
}
103108

109+
private void NoNullFocus()
110+
{
111+
var focusedNode = GetViewport().GuiGetFocusOwner();
112+
if (focusedNode != null)
113+
return;
114+
_tabs.GetTabBar().GrabFocus();
115+
ClearDescription(-1);
116+
}
117+
104118
private void DoDescription(DisplayButton dispButton)
105119
{
106120
string itemName = dispButton.DisplayName.ToUpper();

0 commit comments

Comments
 (0)