Gui -> addWindow -> no close button and how close from

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
knightoflight
Posts: 199
Joined: Sun Aug 24, 2003 5:47 pm
Location: Germany

Gui -> addWindow -> no close button and how close from

Post by knightoflight »

again beginner questions - i cant find, maybe im blind ;-)
- how can i switch off the close button from the window, of have i to screw in the irrlichtengine ?
- how can i close the window from program ? i tried destructor, but doesnt work, or ???
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

There is currently really no method of getting a pointer to the fixed buttons on the window, instead of maybe window->getElementFromPoint(). You could use this until there is a better version.

For closing the window try yourWindow->remove();
knightoflight
Posts: 199
Joined: Sun Aug 24, 2003 5:47 pm
Location: Germany

Post by knightoflight »

i was blind, ok, the remove is in the docu, but if i try, i get a
"Debug Assertion Failed !
File dbgdel.cpp line 47
Expression _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)"

heres the code, i press ESC the window opens, the FPS-camera ist stopped,
i click on continue, the FPS-camera ist started, the computer crashes, have it to remove the buttons, too?:
...
switch(event.GUIEvent.EventType)
{
case EGET_BUTTON_CLICKED:
...
if (id == 107)
{
smgr->setActiveCamera(camera);
window->remove();
return true;
}
}
}
...
switch(event.KeyInput.Key)
{
case KEY_ESCAPE:
{
smgr->setActiveCamera(0);
window = guienv->addWindow(
rect<s32>(50 , 50 , 400 , 300 ), 0, -1, L"Menu");
guienv->addButton(rect<s32>(30,30,100,60), window, 104, "End game");
guienv->addButton(rect<s32>(30,70,100,100), window, 105, L"Load");
guienv->addButton(rect<s32>(30,110,100,140), window, 106, L"Save");
guienv->addButton(rect<s32>(30,150,100,180), window, 107, L"Continue");
return true;
}
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Are you sure that the window pointer is valid when you call window->remove?
Try it out, and e.g. set a new text to the window instead of removing it.
knightoflight
Posts: 199
Joined: Sun Aug 24, 2003 5:47 pm
Location: Germany

Post by knightoflight »

the window should be valid, the continue-button is on the window and it works too -
but i changed to the setVisible() like you and Mr [dx/x]=HUNT3R wrote in the thread "menu problems", that works.
Soldier of infortune
Posts: 29
Joined: Fri Sep 19, 2003 8:36 am

Post by Soldier of infortune »

I added a gui on my game like the tutorial 5 (user interface example)

For getting keyboard input events :

Code: Select all

class MyEventReceiver : public IEventReceiver
{
public:
	virtual bool OnEvent(SEvent event)
	{

		if (event.EventType == EET_GUI_EVENT)
		{
			s32 id = event.GUIEvent.Caller->getID();
			IGUIEnvironment* env = device->getGUIEnvironment();

			switch(event.GUIEvent.EventType)
			{

			case EGET_BUTTON_CLICKED:

				if (id == 101)
				{
					device->closeDevice();
					return true;
				}

				break;
			}
		}

		if (perso2_corps != 0 && event.EventType == irr::EET_KEY_INPUT_EVENT )
		{
			switch(event.KeyInput.Key)
			{
			case KEY_KEY_G:
				{
					core::vector3df r = perso2_corps->getRotation();
					if (r.Y == 360)
						r.Y=0.0f;
					else	
						r.Y += 1.0f;
					
					perso2_corps->setRotation(r);
				}	
			}
		}
	}
};

But when i move the mouse on these buttons, there is a seg fault !

How can i resolve this big problem ?

Sam
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

@knightToFlight: Your problem is solved with the version 0.4.1, there was a bug, sorry.

@soldier: Where exactly does the seg fault occur?
Soldier of infortune
Posts: 29
Joined: Fri Sep 19, 2003 8:36 am

Post by Soldier of infortune »

I can move my camera and my model with the keyboard.
I don't control the cam with the mouse , I don't use the camerafps.
There are 3 buttons, by example there is the Quit button.
When I move the mouse on this button, the application stops : there is a segmentation fault .

Soldier of Infortune

ps : I work on Linux
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

I meant where in the code does the access violation occur? Somewhere in the engine or in your code? And with which version of then engine are you working? 0.4.1?
Soldier of infortune
Posts: 29
Joined: Fri Sep 19, 2003 8:36 am

Post by Soldier of infortune »

I think the error comes in my code :(
I work with the 0.4 version of the engine.
Have you patch the new code for working under Linux ?
cf :
http://irrlicht.sourceforge.net/phpBB2/ ... ight=linux

Sam/Soldier
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Sure, version 0.4.1 fixes most of the problems.
Soldier of infortune
Posts: 29
Joined: Fri Sep 19, 2003 8:36 am

Post by Soldier of infortune »

I recompil the latest version of the engine, i have the same error (seg faul).
My code is-it correct ?
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

The part you posted is correct as far as I could see. But maybe there's a problem in another part?
Soldier of infortune
Posts: 29
Joined: Fri Sep 19, 2003 8:36 am

Post by Soldier of infortune »

Ha ! I solve my problem , it was a error programming.

Sam
Post Reply