Game Development Community

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:

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;

#1
08/17/2009 (6:28 pm)
Logged as THREED-670
#2
08/19/2009 (1:41 pm)

Merged. Thanks for the fix, Konrad.