Game Development Community

GuiBitmapButtonCtrl

by Howard Dortch · in Torque Game Engine · 06/07/2004 (5:37 am) · 15 replies

I can't get text to show up on my button. Which profile should I be using?

#1
06/07/2004 (8:07 am)
A GuiBitmapButtonCtrl just shows an image, with no text. If you want to show text, you'll have to draw it into the image, or use another control.
#2
06/07/2004 (8:20 am)
Well it had a text field so I figgered it would display text. When you say draw it onto the image do you mean in the origional graphic or using the engine text function?
#3
06/07/2004 (8:27 am)
I found this in the GuiBitmapButtonCtrl code

Point2I textPos = offset;
if(mDepressed)
textPos += Point2I(1,1);
dglSetBitmapModulation( mProfile->mFontColor );
renderJustifiedText(textPos, mBounds.extent, mButtonText);

Looks like it should print text.
#4
06/07/2004 (8:27 am)
He means on the button image itself.

I just went through learning this control this weekend, so here are some of the things that I figured out (note, this is in the forums back in an old 2003 thread, but took me some time to track down).

--The button text field has no effect when you are using a GuiBitmapButtonCtrl

The engine requires at least one button graphic ("Normal"), and allows up to 4. They are the following:

yourbuttonimagename_i.png : Inactive
yourbuttonimagename_d.png : button is "Down"
yourbuttonimagename_h.png : button is "highlighted", or being "hovered" over
yourbuttonimagename_n.png : "Normal"--what it looks like normally.

Most of the time I assume, you'd want to have the "Normal" button with one graphic, the "hover" with a second, and the "down" with a third. The text for each button state (if it needs to change) is in the picture itself.

In the profile for the button, the image should just have one filename: yourbuttonimagename (no underscores with state, or .png/jpg extention. The code takes care of that for you).

Hope this helps.

Here is a quick example of what the buttons may look like: The Air button set

The images don't show too well in a browser, but if you look carefully, each is subtly different to show visually the button's state.
#5
06/07/2004 (9:29 am)
Yeah I can display all the buttons normal, hover, select just no text. Seems like that really should be part of the engine since it's a natural thing to do so now the only way to get around this is make 3 buttons for each control rather than one.
#6
06/07/2004 (9:31 am)
Well, the idea of a GuiBitmapButtonCtrl is to provide a graphical image instead of "basic" buttons. If all you want is basic buttons, try GuiButtonCtrl--text works fine on that, and there are basic states already programmed in.
#7
06/10/2005 (12:20 pm)
How would you go about using a GuiButtonCtrl, but having the button's image different than the plain old beige square? A different bitmap, as done in Legends. That is not a GuiBitmapButtonCtrl, but a regular GuiButtonCtrl.
#8
06/10/2005 (12:31 pm)
Just create a guiBitmapButtonCtrl then right click it (so the next control will be a child of it) and create a guiTextCtrl as a Child of the control, so the text is within the button.
#9
06/10/2005 (12:32 pm)
Howard, there is a GuiBitmapButtonTextCtrl but it was not implemented as a CONOBJECT (IMPLEMENT_CONOBJECT)...so, in guiCanvas.cc somewhere with the other IMPLEMENT_CONOBJECT statements add:
IMPLEMENT_CONOBJECT(GuiBitmapButtonTextCtrl);
and you will have it available in the editor. This will do just what you want. Have fun :)
#10
06/10/2005 (12:49 pm)
@ Matt Langley: Yeah, that works (Thanks for teaching me something new about right clicking on Gui objects, never looked into that), however the text is not part of the button, so when you mouse over the text that is on top of the button, you cannot click the button. The text seems to block the activity of the GuiBitmapButtonCtrl.

Edit: If you use a GuiMLTextNoSelectProfile, it works. It's obvious, TextNoSelect, makes the text not be able to be selected, thus when you mouse over, it selects the button as usual.

Thanks for the child help!
#11
06/10/2005 (12:58 pm)
Ouch, your right, didn't even think about the noSelect pofile... thx Jacob, thought I remembered seeing that in the source
#12
07/29/2005 (1:25 pm)
Hi,

just seen this thread. I have a problem with the GuiBitmapButtonCtrl.

In the editor I create such a button, then try
to assign a bitmap to it. My bitmap is located in:

demo/client/ui/button/buy_now_n.png

and I have also a buy_now_h.png

In the 'bitmap' field I enter:

demo/client/ui/button/buy_now

Then apply the changes.
1) No bitmap shown, even after saving/reloading the demo
2) I can enter a button text and it is displayed. It
should not if I follow the comments here. The button
behaves exactly like a GuiButtonCtrl in fact.

What's strange also is that
the SDK binary (I recompiled it) gives
me a version 1.2 though the file name
is TorqueGameEngineSDK-1.3.bin

This is on Linux with Torque 1.3.

Any help is appreciated.
#13
07/29/2005 (1:43 pm)
@Pascal: Try leaving out the demo part, so use 'client/ui/button/buy_now'

Just a guess, not promises! :)

B--
#14
07/29/2005 (2:01 pm)
@Brandon

Thank you,

I've finally (err, just after posting) found where
the problem is : the bitmaps have to be located
in the same tree than the set of scripts currently
executed. I can't give a reference to a picture
in a random place...

I'm happy now - I have nifty pictures :-)
#15
05/21/2008 (11:13 pm)
Hi,
I want to create a single 2d image box in menu having both guibitmapbuttoncontrol along with mouse hover within itself,so that when i move or hover my mouse on that box it should diplay another big image on the screen.And now if i click on same box it will act as button to call some function.

How to get this two, button and hover cntrl on single 2d image box or grid?? What control should i used and how???