Commit 39b66e4b authored by ElderLich's avatar ElderLich

Bug Fix: Fix deck search text changing on arrow keys

SelectionInputField from applying arrow-key numeric +/- edits unless the input is configured as integer-only, so deck editor searches like -28 no longer mutate while numeric fields still step correctly.
parent 08a8d2c2
...@@ -65,10 +65,7 @@ namespace MDPro3.UI ...@@ -65,10 +65,7 @@ namespace MDPro3.UI
{ {
if(InputField.isFocused) if(InputField.isFocused)
{ {
if (int.TryParse(InputField.text, out int num)) TryAdjustFocusedIntegerValue(upNum);
{
InputField.text = (num + upNum).ToString();
}
return; return;
} }
else if (navigationEvent.onUpNavigation.GetPersistentEventCount() > 0) else if (navigationEvent.onUpNavigation.GetPersistentEventCount() > 0)
...@@ -81,10 +78,7 @@ namespace MDPro3.UI ...@@ -81,10 +78,7 @@ namespace MDPro3.UI
{ {
if (InputField.isFocused) if (InputField.isFocused)
{ {
if (int.TryParse(InputField.text, out int num)) TryAdjustFocusedIntegerValue(-upNum);
{
InputField.text = (num - upNum).ToString();
}
return; return;
} }
else if (navigationEvent.onDownNavigation.GetPersistentEventCount() > 0) else if (navigationEvent.onDownNavigation.GetPersistentEventCount() > 0)
...@@ -97,10 +91,7 @@ namespace MDPro3.UI ...@@ -97,10 +91,7 @@ namespace MDPro3.UI
{ {
if (InputField.isFocused) if (InputField.isFocused)
{ {
if (int.TryParse(InputField.text, out int num)) TryAdjustFocusedIntegerValue(-rightNum);
{
InputField.text = (num - rightNum).ToString();
}
return; return;
} }
else if (navigationEvent.onLeftNavigation.GetPersistentEventCount() > 0) else if (navigationEvent.onLeftNavigation.GetPersistentEventCount() > 0)
...@@ -113,10 +104,7 @@ namespace MDPro3.UI ...@@ -113,10 +104,7 @@ namespace MDPro3.UI
{ {
if (InputField.isFocused) if (InputField.isFocused)
{ {
if (int.TryParse(InputField.text, out int num)) TryAdjustFocusedIntegerValue(rightNum);
{
InputField.text = (num + rightNum).ToString();
}
return; return;
} }
else if (navigationEvent.onRightNavigation.GetPersistentEventCount() > 0) else if (navigationEvent.onRightNavigation.GetPersistentEventCount() > 0)
...@@ -128,5 +116,19 @@ namespace MDPro3.UI ...@@ -128,5 +116,19 @@ namespace MDPro3.UI
base.OnNavigation(eventData); base.OnNavigation(eventData);
} }
private void TryAdjustFocusedIntegerValue(int delta)
{
if (!AllowArrowAdjustForFocusedInput())
return;
if (int.TryParse(InputField.text, out int num))
InputField.text = (num + delta).ToString();
}
private bool AllowArrowAdjustForFocusedInput()
{
return InputField.contentType == TMP_InputField.ContentType.IntegerNumber
|| InputField.characterValidation == TMP_InputField.CharacterValidation.Integer;
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment