How do you (properly) add a text label in t2d?
by Jason Swearingen · in Torque Game Builder · 12/06/2005 (1:38 am) · 8 replies
I'd like to add a text label to the screen, such as shooterdemo's "Score" GuiTextCtrl.
However, I cant seem to properly add a label to the screen.
I try adding a GuiTextCtrl to the GuiCanvas, which displays the text, but it is always on the middle-left of the screen, and it disables the drop-down menus on top
Is there a resource or an example showing how to properly add a text label to a game?
thanks,
-Jason
However, I cant seem to properly add a label to the screen.
I try adding a GuiTextCtrl to the GuiCanvas, which displays the text, but it is always on the middle-left of the screen, and it disables the drop-down menus on top
Is there a resource or an example showing how to properly add a text label to a game?
thanks,
-Jason
#2
note the position and extent variables
12/06/2005 (11:34 am)
You can do something like thisnew GuiMLTextCtrl(textLabel) {
text = "Blah";
extent = "30 10";
position = "25 25";
};
// add the control
mainScreenGui.add(textLabel);note the position and extent variables
#3
is there a console function that shows a list of all currently defined objects?
i will try adding to another Gui object instead of the canvas, see how that works.
thanks for the info Matthew
-Jason
12/06/2005 (12:24 pm)
@Matthew i used the .extent and .position variables, but when adding it to the 'canvas' GuiCanvas it doesnt work properly.is there a console function that shows a list of all currently defined objects?
i will try adding to another Gui object instead of the canvas, see how that works.
thanks for the info Matthew
-Jason
#4
You cant add a GuiTextCtrl directly to the current GuiCanvas. you should instead add it to the mainScreenGui object like Matthew described.
(otherwise you'll have the bug i was mentioning)
12/06/2005 (9:01 pm)
I figured out what was wrong.You cant add a GuiTextCtrl directly to the current GuiCanvas. you should instead add it to the mainScreenGui object like Matthew described.
(otherwise you'll have the bug i was mentioning)
#5
- Melv.
12/06/2005 (11:17 pm)
I believe that the root GUI always gets sized to the canvas as it doesn't make sense to have parts of the screen not drawn to. I'd need to go back and check that but I believe it's true.- Melv.
#6
12/07/2005 (10:50 am)
I beleive Melv is correct, the root GUI should automatically resize to the canvas.
#7
ie
12/07/2005 (10:59 am)
A generic way to "add" it the canvas is use Canvas.getContent() which returns the root gui control of the canvas.ie
Canvas.getContent().add( textLabel );
#8
12/07/2005 (11:49 am)
@Owen: that is awesome, thanks for that tip!
Torque Owner Jason Swearingen
here's the psudo code for what I'm doing (that doesnt work properly)
this displays text to the screen, but i cant control it's location (it always appears on the middle-left edge) and doing the .Add seems to render the other GUI elements inactive to mouse clicks (specifically, i cant click on the default drop-down menu on top)
If anyone can tell me the proper way to add a label, I would be very thankful!
---
edit: and while i'm asking, knowing how to create a text box that takes user input would be swell.