Game Development Community

Button highlighting question

by Steve D · in Torque Game Builder · 09/18/2010 (5:08 pm) · 4 replies

Hello everyone! When I add a default GuiBitmapButtonTextCtrl with default text and I place the mouse over it the text changes color. When I give it a custom profile which includes a custom font the text still highlights. However, when I change it to a custom bitmap the text doesn't highlight anymore. Does anyone know how to make the text highlight with a custom bitmap? Or does only work when you have the graphic_r in the gui directory?

#1
09/19/2010 (12:26 am)

That's a bug in GuiBitmapButtonTextCtrl. When you don't have a texture assigned, it renders through the code in GuiButtonCtrl which correctly changes the font color based on activeness and highlighting state. However, as soon as a bitmap is assigned, GuiBitmapButtonTextCtrl's render code takes over and it does this:

dglSetBitmapModulation( mProfile->mFontColor );

which is wrong. It should be

ColorI fontColor   = mActive ? (highlight ? mProfile->mFontColorHL : mProfile->mFontColor) : mProfile->mFontColorNA;
      dglSetBitmapModulation( fontColor );

#2
09/19/2010 (7:02 pm)
Hi Rene, thanks for the reply. I can't find any guibitmapbuttonTextCtrl, there is only a guibitmapbuttonCtrl, is that correct?

When I try and compile I get a "highlight" is an undeclared identifier, any thoughts?
#3
09/19/2010 (7:09 pm)

GuiBitmapButtonTextCtrl is actually sandwiched into guiBitmapButtonCtrl.h|cc. Look at the bottom of the file.

My untried quickfix (which actually is just code copied from GuiButtonCtrl::onRender) indeed won't compile. The following should, though:

ColorI fontColor   = mActive ? ( mMouseOver ? mProfile->mFontColorHL : mProfile->mFontColor) : mProfile->mFontColorNA;
dglSetBitmapModulation( fontColor );

Hope this does the job.
#4
09/20/2010 (2:11 am)
Works great, thank you very much!