Torque 3D Beta 5 Bug - GuiTextEditCtrl text pos bug [+fix]
by Konrad Kiss · in Torque 3D Professional · 08/14/2009 (9:42 am) · 2 replies
This happens only occasionally - depending on what positioning values you feed your control. Consider the code below from GuiTextEditCtrl:
Every variable in there is a S32 except the return value of mFont->getHeight() which is a U32. It can cause a negative value to be cast as a U32, resulting in pretty wild drawPoint.y values.
What the user sees is a control, where the entered text can not be seen (it's written somewhere far off the visible canvas), and the selected text is a filled rect without a text.
Proposed fix:
drawPoint.y += ( ( drawRect.extent.y - paddingLeftTop.y - paddingRightBottom.y - mFont->getHeight() ) / 2 ) + paddingLeftTop.y;
Every variable in there is a S32 except the return value of mFont->getHeight() which is a U32. It can cause a negative value to be cast as a U32, resulting in pretty wild drawPoint.y values.
What the user sees is a control, where the entered text can not be seen (it's written somewhere far off the visible canvas), and the selected text is a filled rect without a text.
Proposed fix:
drawPoint.y += ( ( drawRect.extent.y - paddingLeftTop.y - paddingRightBottom.y - (S32)mFont->getHeight() ) / 2 ) + paddingLeftTop.y;
About the author
http://about.me/konrad.kiss
Torque 3D Owner Kenneth Holst
Default Studio Name