Hello, @Stephan_B
I am having an issue where I have a TMPro Input field with a minOffset and maxOffset where left is set to 180, and right is set to 0. I am having an issue where when pressing the backspace key, it gets offset dramatically (by -180) so that it becomes left = 0, and right = 90.
I seem to have tracked down this bug to the TMP_InputField.cs script from lines 3866. I can see that it is detecting where the first character and last character are, and then it is using these values against the anchored position to determine if it should make an offset. I am not sure how to fix this bug properly, so I thought you may have some ideas, also I think it is good for you to know about this issue.
The code is here for convenience:
// Special handling of backspace
if (m_isLastKeyBackspace)
{
float anchoredPositionX = m_TextComponent.rectTransform.anchoredPosition.x;
float firstCharPosition = localPosition.x + textViewportLocalPosition.x + textComponentLocalPosition.x + m_TextComponent.textInfo.characterInfo[0].origin - m_TextComponent.margin.x;
float lastCharPosition = localPosition.x + textViewportLocalPosition.x + textComponentLocalPosition.x + m_TextComponent.textInfo.characterInfo[m_TextComponent.textInfo.characterCount - 1].origin + m_TextComponent.margin.z + m_CaretWidth;
if (anchoredPositionX > 0.0001f && firstCharPosition > viewportWSRect.xMin)
{
float offset = viewportWSRect.xMin - firstCharPosition;
if (anchoredPositionX < -offset)
offset = -anchoredPositionX;
m_TextComponent.rectTransform.anchoredPosition += new Vector2(offset, 0);
AssignPositioningIfNeeded();
}
else if (anchoredPositionX < -0.0001f && lastCharPosition < viewportWSRect.xMax)
{
float offset = viewportWSRect.xMax - lastCharPosition;
if (-anchoredPositionX < offset)
offset = -anchoredPositionX;
m_TextComponent.rectTransform.anchoredPosition += new Vector2(offset, 0);
AssignPositioningIfNeeded();
}
m_isLastKeyBackspace = false;
}
Please let me know what you think.