CGUITextBox, scrolling, static text.

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.

Is this usefull?

Add it to the Wiki!
24
89%
Nope
3
11%
 
Total votes: 27

MikeR
Posts: 767
Joined: Sun Dec 26, 2004 4:03 pm
Location: Northern California USA
Contact:

Post by MikeR »

I'm getting a page not found error when attempting to download.
If it exists in the real world, it can be created in 3d

Sys specs:
AMD 3700+ 64 processor
1.0 gb ram
e-Geforce 6600 graphics 256 mb onboard ram
MasterD
Posts: 153
Joined: Sun Feb 15, 2004 4:17 pm
Location: Lübeck, Germany
Contact:

Post by MasterD »

The link works for me, alternatively you can use

http://www.pltg-blacksun.de/yass/downloads/TextBox.rar

which is a more direct download link.
YASS - Yet another Space Shooter
under Devolpment, see http://yass-engine.de
sivagiri
Posts: 22
Joined: Sat Jun 10, 2006 4:31 pm

Post by sivagiri »

gui::IGUIElement::IGUIElement' : no overloaded function takes 4 arguments


this what it writes for error for this :oops:

"CGUITextBox::CGUITextBox(irr::gui::IGUIFont * font, const wchar_t * text,
IGUIEnvironment* environment, core::rect<s32> rectangle,
IGUIElement* parent, s32 id)
: IGUIElement(environment, parent, id, rectangle)
{..."


Whats the prob?
sivagiri
Posts: 22
Joined: Sat Jun 10, 2006 4:31 pm

Post by sivagiri »

THANKS :oops:
jolindien
Posts: 16
Joined: Sun Jul 16, 2006 3:00 pm
Location: Lyon (France)

Post by jolindien »

If you want to scroll the text in the CGUITextBox with your mouse wheel, just add this code in the bool CGUITextBox::OnEvent(SEvent event) of CGUITextBox.cpp.
This code comes from CGUIListBox.cpp.

Code: Select all

switch(event.EventType)
	{
	case EET_MOUSE_INPUT_EVENT:
		{
			switch(event.MouseInput.Event)
			{
			case EMIE_MOUSE_WHEEL:
				m_pScrollbar->setPos(m_pScrollbar->getPos() + (s32)event.MouseInput.Wheel*-10);
				irr::s32 line = m_pScrollbar->getPos();
				setVisibleText(line);
				return true;
			}
		}
		break;
	}
[/b]
Yeurl
Posts: 31
Joined: Thu Apr 13, 2006 9:34 am

Post by Yeurl »


from sivagiri

Code: Select all

gui::IGUIElement::IGUIElement' : no overloaded function takes 4 arguments


this what it writes for error for this Embarassed

"CGUITextBox::CGUITextBox(irr::gui::IGUIFont * font, const wchar_t * text,
IGUIEnvironment* environment, core::rect<s32> rectangle,
IGUIElement* parent, s32 id)
: IGUIElement(environment, parent, id, rectangle)
{..."


Whats the prob?
I have the same problem, how to do ?
MasterD
Posts: 153
Joined: Sun Feb 15, 2004 4:17 pm
Location: Lübeck, Germany
Contact:

Post by MasterD »

I'm sorry to respond that late, but I lost a bit of the sight to this topic.

The problem is that between Irrlicht 0.11 and 0.12, the API of IGUIElement changed, and I forgot to update the resource on my server.

In 0.12, there is a added first Parameter of the constructor of IGUIElement: EGUI_ELEMENT_TYPE type which needs to be set to EGUIET_ELEMENT because this is a custom Element.

I've updated the resource -> here and also added the very useful Mousewheel scrolling feature, posted by julindien, thanks to you.

Currently the Irrlicht wiki is down, I will update the code there as soon as I see it online again.
YASS - Yet another Space Shooter
under Devolpment, see http://yass-engine.de
Namek Kural
Posts: 81
Joined: Sun Sep 09, 2007 7:01 pm
Location: BW, Germany

Post by Namek Kural »

I have problems using it in irrlich 1.4, does it work for anyone? How can I solve the problem that I can't scroll the text anymore? I can move the scrollbar but the text doesn't move. :?
Namek Kural
Posts: 81
Joined: Sun Sep 09, 2007 7:01 pm
Location: BW, Germany

Post by Namek Kural »

Please help! I really need it and I don't know how to fix it :cry:
Luke Dean
Posts: 9
Joined: Tue Dec 11, 2007 5:59 am

Post by Luke Dean »

I just got it working with 1.4.
Here's what I did.

First, the method declaration for OnEvent didn't match what was in IEventReceiver, so it wasn't even getting called. It should be

Code: Select all

OnEvent(const SEvent& event)
not

Code: Select all

OnEvent(SEvent event)
After making that change in the .h and .cpp, the box started receiving events, but the text still wouldn't scroll. There's some kind of problem in the event handler. I've spent a few days trying to understand Irrlicht's event handler, and much of it still eludes me. What I *think* is happening here is that the first "if" block which handles scroll wheel events is generating a new GUI scrollbar event (or corrupting the current event?) when it does its setPos on the scrollbar. Then the second "if" block picks up that event and tries to do... something....
Anyway, I fixed it by putting an

Code: Select all

else
between the two "if" blocks to ensure that a single pass through OnEvent either handles the mouse event or the GUI event, but not both.
It works now! :)

:?: I have a couple of questions too.
In the demo program, since the box is created with "new" should it not be dropped explicitly someplace too?
Is it possible to make this box work with IGUIEnvironment->addGUIElement(), and if so, what would that look like? I'm still quite new to Irrlicht and C++.

Thank you everybody for this code!

EDIT:
Whoops. My "else" didn't completely fix it. As soon as the parent received an event, the text scrolling broke again and couldn't be fixed. A better solution is to have each "if" block return "true" as soon as they handle the event, and have OnEvent return "false" at the bottom if it doesn't actually handle an event. I still don't have this working completely right with respect to parent events. The heirarchy of event handling still confuses me.
Namek Kural
Posts: 81
Joined: Sun Sep 09, 2007 7:01 pm
Location: BW, Germany

Post by Namek Kural »

Yeah! I also tried the thing with the OnEvent declaration but as you said this doesn't fix it.

If anybody knows how to fix it completely, please post the solution here :roll:

Thanks Luke Dean for your post, I think this will help very much!
Namek Kural
Posts: 81
Joined: Sun Sep 09, 2007 7:01 pm
Location: BW, Germany

Post by Namek Kural »

Hey Luke Dean, I love you!!!

You really did it! For me, the GUITextBox now works perfectly. Which problems do you get now?

The return true/false thing fixed it all for me :P
Luke Dean
Posts: 9
Joined: Tue Dec 11, 2007 5:59 am

Post by Luke Dean »

Namek Kural wrote: Which problems do you get now?
I think it was just a case of my expectations not matching the author's intentions. :) Now that I see how this kind of thing is done, I'm making my own GUI elements that do exactly what I want them to do.
admgamer
Posts: 21
Joined: Tue Feb 12, 2008 10:49 am

Post by admgamer »

anyone know how to make this scroll to the bottom of the textbox?

Ive created a function that basically does the same as setVisibleText but dont know how to change it so it sets the position of the scroll bar to the bottom of the text box. Thought you might do it with the height of the scrollbar control but to no avail
ibax
Posts: 193
Joined: Thu Jun 21, 2007 8:56 am
Location: hungary
Contact:

Post by ibax »

it is very useful, but for me, the textbox isn't scrollable.
how can I fix this?
Post Reply