GuiMLTextCtrl quesiton
by Lateral Punk · in Torque Game Engine · 07/05/2004 (5:08 pm) · 35 replies
Hi,
i'm trying to figure out how to use the GuiMLTextCtrl control. here is my defn:
new GuiMLTextCtrl(display_screen) {
profile = "GuiMLTextProfile";
horizSizing = "right";
vertSizing = "top";
position = "22 49";
extent = "335 150";
minExtent = "8 2";
visible = "1";
lineSpacing = "2";
allowColorChars = "0";
maxChars = "-1";
};
basically i want to have it so that when there is more text then can be put in the extent defined as 335x150, i want it to scroll up. Now looking at some of the funcitons in guiMLTextCtrol.cc i see that i need my MLTextCtrl to have a parent GuiScrollCtrl. but in my case i do not have that. My question is how do i get this "scrolling" to work? Also i require that the background where the text is written to be transparent. I don't need a scroll bar or anything.
i'm trying to figure out how to use the GuiMLTextCtrl control. here is my defn:
new GuiMLTextCtrl(display_screen) {
profile = "GuiMLTextProfile";
horizSizing = "right";
vertSizing = "top";
position = "22 49";
extent = "335 150";
minExtent = "8 2";
visible = "1";
lineSpacing = "2";
allowColorChars = "0";
maxChars = "-1";
};
basically i want to have it so that when there is more text then can be put in the extent defined as 335x150, i want it to scroll up. Now looking at some of the funcitons in guiMLTextCtrol.cc i see that i need my MLTextCtrl to have a parent GuiScrollCtrl. but in my case i do not have that. My question is how do i get this "scrolling" to work? Also i require that the background where the text is written to be transparent. I don't need a scroll bar or anything.
#2
thanks
07/06/2004 (7:11 am)
Thanks for the help, but i was wondering if there is an example that i can use to further clarify how i should do this.thanks
#3
07/06/2004 (7:38 am)
Check out the demo application, the top botton on the main page will take you to a bunch of scrollable Gui ML controls. Or bring up the help window, by hitting F1.
#4
Also another question, if i set maxChars to something like 1024, would crop text from teh beginning or from the end? I ask because i want things to disappear from the top and not trim things at the end of the string..
thanks
07/06/2004 (11:21 am)
Ok i almost have it scrolling..but one more problem..i call addText on the GuiMLTextCtrl passing in my string and false for the reformat parameter..and everything works fine except that the scroll always stays at the top, and does not autoscroll down, which is what i would like. I can't figure out which settng in either guiScrollCtrl or guiMLTextCtrl i would use to fix this sicne i want my text to autoscroll upwards so you see the latest text at the bottom.Also another question, if i set maxChars to something like 1024, would crop text from teh beginning or from the end? I ask because i want things to disappear from the top and not trim things at the end of the string..
thanks
#5
Also another question, if i set maxChars to something like 1024, would crop text from teh beginning or from the end? I ask because i want things to disappear from the top and not trim things at the end of the string..
thanks
07/06/2004 (12:36 pm)
Ok i almost have it scrolling..but one more problem..i call addText on the GuiMLTextCtrl passing in my string and false for the reformat parameter..and everything works fine except that the scroll always stays at the top, and does not autoscroll down, which is what i would like. I can't figure out which settng in either guiScrollCtrl or guiMLTextCtrl i would use to fix this sicne i want my text to autoscroll upwards so you see the latest text at the bottom.Also another question, if i set maxChars to something like 1024, would crop text from teh beginning or from the end? I ask because i want things to disappear from the top and not trim things at the end of the string..
thanks
#6
:<
08/26/2004 (7:47 pm)
I am having the same problem. If someone would finish this thread by actually posting the solution, others like myself would be able to benefit from it too.:<
#7
08/26/2004 (10:45 pm)
I would suggest looking at the Chat Hud for a sample of what you guys want to do.
#8
[START RANT]
I mean, what's the big deal with posting an example. TELL US!! Why is this such a big secret anyway? Look, I'm not some lazy programmer wanting my hand to be held through the entire development of my project!
I just spent the last 4 hours trying to get this damn thing to scroll properly and I cannot do it! There is NO documentation on how the gui system works and I am not having much luck reverse-engineering your scripts. And it's a real kick in the teeth when you tell me to "go look at the Chat HUD script". REALLY!? DUH! Why didn't I think to do that!? ... oh, wait I did.
Look, I don't mean to be this rude but this problem is really p*****g me off!! I simply want the text to scroll properly.
[END RANT]
Here is what I need. I need an input box that when I type text, it will clear itself and put the text into a scroll window when I hit enter. Sounds simple right? ITS NOT!! I can't clear the input box, I can't scroll the text and keep focus at the bottom! I have NO documentation to refer to... VERY FRUSTRATING!!
08/27/2004 (5:51 am)
Uh, yeah, kinda did that already. Can't get it to work. [START RANT]
I mean, what's the big deal with posting an example. TELL US!! Why is this such a big secret anyway? Look, I'm not some lazy programmer wanting my hand to be held through the entire development of my project!
I just spent the last 4 hours trying to get this damn thing to scroll properly and I cannot do it! There is NO documentation on how the gui system works and I am not having much luck reverse-engineering your scripts. And it's a real kick in the teeth when you tell me to "go look at the Chat HUD script". REALLY!? DUH! Why didn't I think to do that!? ... oh, wait I did.
Look, I don't mean to be this rude but this problem is really p*****g me off!! I simply want the text to scroll properly.
[END RANT]
Here is what I need. I need an input box that when I type text, it will clear itself and put the text into a scroll window when I hit enter. Sounds simple right? ITS NOT!! I can't clear the input box, I can't scroll the text and keep focus at the bottom! I have NO documentation to refer to... VERY FRUSTRATING!!
#9
08/27/2004 (10:49 am)
The big deal is, I'm not here to solve your problems. I have a project, a deadline, and digging through scripts and code to figure out to make ML controls scroll in a very specific way which is already implemented somewhere in the engine really isn't at the top of my priority list.
#10
It is a little frustrating. However, Pat is correct. If you just take a little time and check through the "chat" fuction that is in the TGE demo, you'll find what you need.
Also, this community is really good about getting you answers to your questions. It really comes down to time. Sometimes people HAVE time to find the code, copy/paste it into a reply for you. Sometimes they don't have the TIME. This is not to say that they wouldn't LIKE to have the time to do so.
Game development is frustrating in general. If you're not frustrated at some point, then you're not doing it right *wink*. However, don't take out your frustrations on folks pointing you in the right direction.
Also, do a search on TGE Lobby. That is a great lobby resource that "might" help you along your way also.
08/27/2004 (11:13 am)
Ritchey,It is a little frustrating. However, Pat is correct. If you just take a little time and check through the "chat" fuction that is in the TGE demo, you'll find what you need.
Also, this community is really good about getting you answers to your questions. It really comes down to time. Sometimes people HAVE time to find the code, copy/paste it into a reply for you. Sometimes they don't have the TIME. This is not to say that they wouldn't LIKE to have the time to do so.
Game development is frustrating in general. If you're not frustrated at some point, then you're not doing it right *wink*. However, don't take out your frustrations on folks pointing you in the right direction.
Also, do a search on TGE Lobby. That is a great lobby resource that "might" help you along your way also.
#11
08/27/2004 (8:44 pm)
While I do not have the answer to your question, I would like to point out that checking the chat gui as others have suggested is NOT the way to solve the problem. The demo chathud uses a different gui control: GUIMessageVectorCtrl. The implementation is TOTALLY different. A couple years back I did succeed in making the GuiMLTextEditCtrl scroll to the bottom and I wish I had kept the code. If I recall correctly it had something to do with fixing a scrollToBottom() function in the source for the control. No promises, but I hope it points you in the right direction.
#12
I mean, if it's not, prove me wrong! I'd like to see a working example of it.
Thanks Neoaez! I certainly appreciate the constructive feedback.
08/28/2004 (3:46 am)
The guys at GG pointed me to some code (TGELobby) that might have a working example of the scrolltobottom() method... they were right... and it was commented out of the code! I was waiting to hear back from DarkRaven before I posted this:The scrollToBottom() function IS BROKEN!!
I mean, if it's not, prove me wrong! I'd like to see a working example of it.
Thanks Neoaez! I certainly appreciate the constructive feedback.
#13
Add
Add
I tested it real quick and it worked, but since I only spent a few minutes on it, there might be problems or bugs that I didn't see. Feel free to use and improve this code.
08/28/2004 (5:30 am)
I just had a look at the GuiMLTextCtrl to find an answer to this question and discovered that the control does not have a scrollToBottom function, so I implemented it real quick:Add
void scrollToBottom();to guiMLTextCtrl.h
Add
ConsoleMethod( GuiMLTextCtrl, scrollToBottom, void, 2, 2, "Scroll to the bottom of the text.")
{
object->scrollToBottom();
}andvoid GuiMLTextCtrl::scrollToBottom()
{
// If the parent control is not a GuiScrollContentCtrl, then this call is invalid:
GuiScrollCtrl *pappy = dynamic_cast<GuiScrollCtrl*>(getParent());
if ( !pappy )
return;
// Find the last line
Line *walk = mLineList;
Line *last = NULL;
for(Line *walk = mLineList; walk; walk = walk->next)
{
last = walk;
}
pappy->scrollRectVisible(RectI(0, last->y,0, last->y));
}to guiMLTextCtrl.cc and recompile.I tested it real quick and it worked, but since I only spent a few minutes on it, there might be problems or bugs that I didn't see. Feel free to use and improve this code.
#14
08/30/2004 (5:12 pm)
Sweet! Thank you very much!
#15
08/30/2004 (8:46 pm)
I couldn't get it to work. It keeps saying "Unknown command scrollToBottom". While looking at the source I discovered another undocumented command called setAlpha!! That is a kick a$$ command! Why don't any of the other controls have that!?
#16
08/31/2004 (9:32 am)
Hm, it works for me, have you added all the code, especially the ConsoleMethod (assuming the error you get is displayed in the console)? Did you recompile? Any errors there?
#17
guiMLTextCtrl.cc ..check!
AND the other code as well just below their scrolltotop()...
Nothing. I still get " Unknown command scrollToBottom."
I swapped it with scrollToTop and it works fine. I did a "clean" and a "Rebuild All" and I was using the latest CVS download before modifying and I did verify it compiled guiMLTextEditCtrl.cc I also, confirmed I was using the executable I just built. I don't know what I am doing wrong. If you want to persue this off line, contact me at: rthawkcom@yahoo.com
I kinda get the idea the guys at GG want us to implement this code fix on our own before they add it to their production code. I know it will get a good work out with this program I am writing, it swaps data in and out of that window viciously as its bouncing through servers and channels!
08/31/2004 (4:09 pm)
GuiMLTextCtrl.h ...check!// Scroll functions void scrollToTag( U32 id ); void scrollToTop(); void scrollToBottom();
guiMLTextCtrl.cc ..check!
ConsoleMethod( GuiMLTextCtrl, scrollToTop, void, 2, 2, "Scroll to the top of the text.")
{
object->scrollToTop();
}
ConsoleMethod( GuiMLTextCtrl, scrollToBottom, void, 2, 2, "Scroll to the bottom of the text.")
{
object->scrollToBottom();
}AND the other code as well just below their scrolltotop()...
Nothing. I still get " Unknown command scrollToBottom."
I swapped it with scrollToTop and it works fine. I did a "clean" and a "Rebuild All" and I was using the latest CVS download before modifying and I did verify it compiled guiMLTextEditCtrl.cc I also, confirmed I was using the executable I just built. I don't know what I am doing wrong. If you want to persue this off line, contact me at: rthawkcom@yahoo.com
I kinda get the idea the guys at GG want us to implement this code fix on our own before they add it to their production code. I know it will get a good work out with this program I am writing, it swaps data in and out of that window viciously as its bouncing through servers and channels!
#18
I just wanted to be sure, since you just mentioned that you verify the compilation of guiMLTextEditCtrl.cc
If that doesn't help, you can mail me the respective files (guiMLTextCtrl.cc and .h and your .gui that you're using) and I'll have a look.
09/01/2004 (8:41 am)
Just one check, to make sure: the gui control you're using and trying this with is a GuiMLTextCtrl right? Not a GuiMLTextEditCtrl? The code above adds the function to the GuiMLTextCtrl, not to the GuiMLTextEditCtrl, since the ConsoleMethod is quite specific. If you want to add it to that GuiMLTextEditCtrl, add the same changes to the guiMLTextEditCtr.cc and .h, replacing GuiMLTextCtrl with GuiMLTextEditCtrl.I just wanted to be sure, since you just mentioned that you verify the compilation of guiMLTextEditCtrl.cc
If that doesn't help, you can mail me the respective files (guiMLTextCtrl.cc and .h and your .gui that you're using) and I'll have a look.
#19
Here is what you do:
This creates a GuiMessageVectorCtrl
Now the message vector control needs something called a MessageVector to get its text from.
So just make one by doing this:
then when your window is pushed (you know in the ::onWake function) just add this to attach them together:
Now this is the add line function, look over it and get what you need, this adds a line to the bottom and when it reachs $pref::HudMessageLogSize number of lines it will get rid of the top line and add the bottom so will forever stay a certain amount of lines and news lines will be added to the bottom.
Next time, drink some coffee...
-Banshee
09/01/2004 (10:51 am)
If you had looked at the chat hud correctly you would noticed it doesn't use a MLTextCtl, it uses a GuiMessageVectorCtrl. I think your too-bizzy shouting at us to give you the answer, than to look properly! Why did you include your rant above if all it does is make people not want to help you :P.Here is what you do:
This creates a GuiMessageVectorCtrl
new GuiMessageVectorCtrl(ChatHud) {
profile = "ChatHudMessageProfile";
horizSizing = "width";
vertSizing = "height";
position = "1 1";
extent = "252 16";
minExtent = "8 8";
visible = "1";
helpTag = "0";
lineSpacing = "0";
lineContinuedIndex = "10";
allowedMatches[0] = "http";
allowedMatches[1] = "tgeserver";
matchColor = "0 0 255 255";
maxColorIndex = "5";
};Now the message vector control needs something called a MessageVector to get its text from.
So just make one by doing this:
new MessageVector(HudMessageVector);
then when your window is pushed (you know in the ::onWake function) just add this to attach them together:
chatHud.attach(HudMessageVector);
Now this is the add line function, look over it and get what you need, this adds a line to the bottom and when it reachs $pref::HudMessageLogSize number of lines it will get rid of the top line and add the bottom so will forever stay a certain amount of lines and news lines will be added to the bottom.
function ChatHud::addLine(%this,%text)
{
//first, see if we're "scrolled up"...
%textHeight = %this.profile.fontSize;
if (%textHeight <= 0)
%textHeight = 12;
%chatScrollHeight = getWord(%this.getGroup().getGroup().extent, 1);
%chatPosition = getWord(%this.extent, 1) - %chatScrollHeight + getWord(%this.position, 1);
%linesToScroll = mFloor((%chatPosition / %textHeight) + 0.5);
if (%linesToScroll > 0)
%origPosition = %this.position;
//add the message...
while( !chatPageDown.isVisible() && HudMessageVector.getNumLines() && (HudMessageVector.getNumLines() >= $pref::HudMessageLogSize))
{
%tag = HudMessageVector.getLineTag(0);
if(%tag != 0)
%tag.delete();
HudMessageVector.popFrontLine();
}
HudMessageVector.pushBackLine(%text, $LastHudTarget);
$LastHudTarget = 0;
//now that we've added the message, see if we need to reset the position
if (%linesToScroll > 0)
{
chatPageDown.setVisible(true);
%this.position = %origPosition;
}
else
chatPageDown.setVisible(false);
}Next time, drink some coffee...
-Banshee
#20
Yes, I would really appreciate that! Send me your email address, you have mine above. Also you could email me yours and I will compile that. Maybe it has something to do with where I placed the code in the file? It would help isolate what I am doing wrong.
Thanks again! :>>
09/01/2004 (4:22 pm)
Sorry, I ment GuiMLTextCtrl. No, it's the correct type. Here is part of it:new GuiMLTextCtrl(msg_list) {
profile = "GuiDefaultProfile";
horizSizing = "width";
vertSizing = "height";Yes, I would really appreciate that! Send me your email address, you have mine above. Also you could email me yours and I will compile that. Maybe it has something to do with where I placed the code in the file? It would help isolate what I am doing wrong.
Thanks again! :>>
Associate Kyle Carter