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
{
if(InputField.isFocused)
{
if (int.TryParse(InputField.text, out int num))
{
InputField.text = (num + upNum).ToString();
}
TryAdjustFocusedIntegerValue(upNum);
return;
}
else if (navigationEvent.onUpNavigation.GetPersistentEventCount() > 0)
......@@ -81,10 +78,7 @@ namespace MDPro3.UI
{
if (InputField.isFocused)
{
if (int.TryParse(InputField.text, out int num))
{
InputField.text = (num - upNum).ToString();
}
TryAdjustFocusedIntegerValue(-upNum);
return;
}
else if (navigationEvent.onDownNavigation.GetPersistentEventCount() > 0)
......@@ -97,10 +91,7 @@ namespace MDPro3.UI
{
if (InputField.isFocused)
{
if (int.TryParse(InputField.text, out int num))
{
InputField.text = (num - rightNum).ToString();
}
TryAdjustFocusedIntegerValue(-rightNum);
return;
}
else if (navigationEvent.onLeftNavigation.GetPersistentEventCount() > 0)
......@@ -113,10 +104,7 @@ namespace MDPro3.UI
{
if (InputField.isFocused)
{
if (int.TryParse(InputField.text, out int num))
{
InputField.text = (num + rightNum).ToString();
}
TryAdjustFocusedIntegerValue(rightNum);
return;
}
else if (navigationEvent.onRightNavigation.GetPersistentEventCount() > 0)
......@@ -128,5 +116,19 @@ namespace MDPro3.UI
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