FileOpenDialog

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.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

FileOpenDialog

Post by Acki »

Hi,
yes I have a problem, too !!! ;)

In my event receiver I create a FileOpenDialog, like in the UserInterface tutorial...
The dialog appears, but it doesn't respond to any mouse clicks on the buttons or the list box... :shock:
Even more strange I can click where ever I want to move the dialog (also with click outside the dialog) !!! :shock:

the dialog in the UserInterface tutorial works well and I did the same like in the tutorial (I hope ;) )...

Code: Select all

#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

IGUIEnvironment* guienv;
IAnimatedMeshSceneNode* scnNode;

IGUIWindow* window;
IGUIComboBox* meshBuffer;
IGUIComboBox* meshType;
IGUIStaticText* texture0;
IGUIStaticText* texture1;
IGUICheckBox* flag[13];

void getMeshData();
void setMeshData();

class MyEventReceiver : public IEventReceiver{
public:
	virtual bool OnEvent(const SEvent& event){
		if(event.EventType == EET_GUI_EVENT){
			s32 id = event.GUIEvent.Caller->getID();
			switch(event.GUIEvent.EventType){
			  case EGET_BUTTON_CLICKED:{
          if(id == 102){
            //! load texture 0
            guienv->addFileOpenDialog(L"Please choose a file.", true, guienv->getRootGUIElement());
            setMeshData();
            return true;
          }
          if(id == 103){
            //! load texture 1

            setMeshData();
            return true;
          }
			  }
			  default:{
          if(id == 100){
            //! changed mesh buffer
            getMeshData();
            return true;
          }else{
            //! changed material flags and textures
            setMeshData();
            return true;
          }
			  }
			}
		}
		return false;
	}
};

int main(){
  MyEventReceiver receiver;
	IrrlichtDevice* device = createDevice(EDT_DIRECT3D9, dimension2d<s32>(800, 600), 16, false, false, false, &receiver);
	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();
	guienv = device->getGUIEnvironment();
	device->setWindowCaption(L"Manipulating Single Mesh Buffers");

  //! create the GUI
	IGUISkin* skin = guienv->getSkin();
	IGUIFont* font = guienv->getFont("C:/CodeBlocks/AB-AddOn/Media/Irrlicht/fonthaettenschweiler.bmp");
	if(font) skin->setFont(font);
  for(u32 i = 0; i < EGDC_COUNT; i++){
    SColor col = guienv->getSkin()->getColor((EGUI_DEFAULT_COLOR)i);
    col.setAlpha(255);
    guienv->getSkin()->setColor((EGUI_DEFAULT_COLOR)i, col);
  }
  //! craete a window
  window = guienv->addWindow(rect<s32>(430, 50, 780, 450), false, L"Edit");
  //! create a combo box for the mesh buffers
  guienv->addStaticText(L"Mesh Buffer:", rect<s32>(10, 25, 340, 45), false, true, window);
  meshBuffer = guienv->addComboBox(rect<s32>(10, 40, 340, 60), window, 100);
  meshBuffer->addItem(L"0 - Body");
  meshBuffer->addItem(L"1 - Axe");
  //! create a combo box for mesh buffer type
  guienv->addStaticText(L"Type:", rect<s32>(10,70,340,100), false, true, window);
  meshType = guienv->addComboBox(rect<s32>(10, 88, 340, 108), window, 101);
  meshType->addItem(L"Solid");
  meshType->addItem(L"Solid 2 Layer");
  meshType->addItem(L"Lightmap");
  meshType->addItem(L"Lightmap Add");
  meshType->addItem(L"Lightmap M2");
  meshType->addItem(L"Lightmap M4");
  meshType->addItem(L"Lightmap Lighting");
  meshType->addItem(L"Lightmap Lighting M2");
  meshType->addItem(L"Lightmap Lighting M4");
  meshType->addItem(L"Detail Map");
  meshType->addItem(L"Sphere Map");
  meshType->addItem(L"Reflection 2 Layer");
  meshType->addItem(L"Transparent Add Color");
  meshType->addItem(L"Transparent Alpha Channel");
  meshType->addItem(L"Transparent Alpha Channel Ref");
  meshType->addItem(L"Transparent Vertex Alpha");
  meshType->addItem(L"TransparentReflection 2 Layer");
  meshType->addItem(L"Normal Map Solid");
  meshType->addItem(L"Normal Map Transparent Add Color");
  meshType->addItem(L"Normal Map Transparent Vertex Alpha");
  meshType->addItem(L"Paralax Map Solid");
  meshType->addItem(L"Paralax Map Transparent Add Color");
  meshType->addItem(L"Paralax Map Transparent Vertex Alpha");
  meshType->addItem(L"One Texture Blend");
  //! create a text box for the textures
  guienv->addStaticText(L"Texture 0:", rect<s32>(10,115,340,145), false, true, window);
  texture0 = guienv->addStaticText(L"", rect<s32>(10,132,300,152), true, true, window);
  guienv->addButton(rect<s32>(302,132,340,152), window, 102, L"Load");
  guienv->addStaticText(L"Texture 1:", rect<s32>(10,155,340,185), false, true, window);
  texture1 = guienv->addStaticText(L"", rect<s32>(10,172,300,192), true, true, window);
  guienv->addButton(rect<s32>(302,172,340,192), window, 103, L"Load");
  //! create check boxes for material flags
  flag[0] = guienv->addCheckBox(false, rect<s32>(20,200, 160, 220), window, 104, L"Wireframe");
  flag[1] = guienv->addCheckBox(false, rect<s32>(20,225, 170, 245), window, 105, L"Point Cloud");
  flag[2] = guienv->addCheckBox(false, rect<s32>(20,250, 170, 270), window, 106, L"Gouraud Shading");
  flag[3] = guienv->addCheckBox(false, rect<s32>(20,275, 170, 295), window, 107, L"Lighting");
  flag[4] = guienv->addCheckBox(false, rect<s32>(20,300, 170, 320), window, 108, L"ZBuffer");
  flag[5] = guienv->addCheckBox(false, rect<s32>(20,325, 170, 345), window, 109, L"ZWrite");
  flag[6] = guienv->addCheckBox(false, rect<s32>(20,350, 170, 370), window, 110, L"Backface Culling");
  flag[7] = guienv->addCheckBox(false, rect<s32>(180,200, 350, 220), window, 111, L"Bilinear Filter");
  flag[8] = guienv->addCheckBox(false, rect<s32>(180,225, 350, 245), window, 112, L"Trilinear Filter");
  flag[9] = guienv->addCheckBox(false, rect<s32>(180,250, 350, 270), window, 113, L"Anisotropic Filter");
  flag[10] = guienv->addCheckBox(false, rect<s32>(180,275, 350, 295), window, 114, L"Fog");
  flag[11] = guienv->addCheckBox(false, rect<s32>(180,300, 350, 320), window, 115, L"Normalise Normals");
  flag[12] = guienv->addCheckBox(false, rect<s32>(180,325, 350, 345), window, 116, L"Texture Wrap");

	//! load a mesh
	IAnimatedMesh* mesh = smgr->getMesh("data/dwarf2.x");
	scnNode = smgr->addAnimatedMeshSceneNode(mesh);
  scnNode->setMaterialFlag(EMF_LIGHTING, false);
  scnNode->setPosition(core::vector3df(-40,-40,100));
  scnNode->setRotation(core::vector3df(0,-45,0));
  scnNode->setAnimationSpeed(500);

  //! get mesh datas
  getMeshData();

	// setup and run Irrlicht render loop
  smgr->addCameraSceneNode();
	while(device->run()){
		driver->beginScene(true, true, video::SColor(0,0,0,0));
		smgr->drawAll();
		guienv->drawAll();
		driver->endScene();

	}
	device->drop();
	return 0;
}

void setMeshData(){
  // this won't work for you, because it uses new IrrExtensions
}

void getMeshData(){
  // this won't work for you, because it uses new IrrExtensions
}
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Please reduce problem reports to the minimum. I suspect 90% of the code above has no relevance to your problem. Also it would help to have brackets which actually help to find out how much indented a line should be.

Maybe you return true for those events in your receiver. Try replacing all the return true with return false as first experiment.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

no, it doesn't matter if I return true or false... ;)
As I said I did the same like in the UserInterface tutorial and it also returns true (but to be sure I also testet to return false)...

the problem seems to be inside the event receiver, wich is not to big to analyse... ;)

also I added the whole code, so people can test the code I'm using without the need to guess what I did there... ;)
and if I didn't post the whole code, you'll probably say that I missed some code so you can't see what I did... :lol:

and I think the code is well formatted, even some brackets are a little bit shifted because of copy/paste, I think... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

I think it is the return value. MyEventReceiver is reporting that it's consuming every EET_GUI_EVENT except for some EGET_BUTTON_CLICKED. I assume that's stopping the file dialog getting focus, or some other critical event.

When I change this...

Code: Select all

            setMeshData();
            return true;
...to this...

Code: Select all

            setMeshData();
            return false;
It Works For Me.
Last edited by rogerborg on Thu Feb 07, 2008 5:37 pm, edited 3 times in total.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I guess it's in g/setMeshData
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

@hybrid: no, I tested it with and without them... ;)

but I got the error, rogerborg is right !!! :)
I didn't mention that there is this little problem with the default block, yes it always returns true there... :oops:

thx ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Acki wrote:and if I didn't post the whole code, you'll probably say that I missed some code so you can't see what I did... :lol:
Well, you found it, so everythings fine. But just to to get my point for that across: You should post which compiles and and contains your problem, but nothing beside it.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Or not. This was fine, IMO. I don't have a problem with letting the compiler and debugger take the strain, and I'd rather have a full listing that definitely exhibits the behaviour than a hand-edited subset that might not.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

CuteAlien wrote:Maybe you return true for those events in your receiver. Try replacing all the return true with return false as first experiment.
So why didn't this bring a solution in the first place :?:
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

CuteAlien wrote:But just to to get my point for that across: You should post which compiles and and contains your problem, but nothing beside it.
Du brauchst nicht verbissen nach etwas zu suchen, nur um mir eins auszuwischen... :twisted:
Ich denke, ich weiß wie man hier eine Frage stellt, und außerdem ist der Compiler hier irrelevant... ;)

@hybrid: well, I changed the return value inside the (at that time in my opinion the only relevant) case block for the dialog...
I didn't recognise that the problem was in the default block... :oops:
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Acki wrote:
CuteAlien wrote:But just to to get my point for that across: You should post which compiles and and contains your problem, but nothing beside it.
Du brauchst nicht verbissen nach etwas zu suchen, nur um mir eins auszuwischen... :twisted:
Ich denke, ich weiß wie man hier eine Frage stellt, und außerdem ist der Compiler hier irrelevant... ;)
Eigentlich wollte ich helfen, aber schätze irgendwas kommt da falsch an. Ich hab keinen Grund dir eines auszuwischen und wenn du denkst ich wollte das, dann liest du hier etwas rein das ich so ganz sicher nicht reinbringen wollte. Mir gehts einfach nur darum dass kurze Posts es eben leichter machen zu helfen, vlt. scheitert es hier an den englischkenntnissen von uns beiden, keine Ahnung, aber das war wirklich alles um das es mir hier ging.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Das Du mir helfen wolltest ist schon klar, und das begrüße ich auch sehr... :)
Aber Du solltest mich mittlerweile gut genug kennen, um zu wissed, dass ich weiß was ich hier mache (was nicht zwangsläufig ausschließt, dass ich auch mal Fehler mache)... ;)
Wegen dem Sourcecode: es ist immer besser ein paar Zeilen zuviel zu posten, anstatt den relevanten Teil zu vergessen... ;)
Und der Code ist nun wirklich nicht zu groß oder kompliziert um ihn zu verstehen... ;)
z.B. hier fehlen die relevanten Code-Zeilen, weshalb keiner helfen kann: http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=26179
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Acki wrote: Wegen dem Sourcecode: es ist immer besser ein paar Zeilen zuviel zu posten, anstatt den relevanten Teil zu vergessen... ;)
Was der Grund war warum ich so extrem pedantisch und genau gesagt habe wieviel ein Code zum posten enthalten sollte. Perfekt ist - er compiliert, er startet und er enthält das Problem. Solange das Problem noch auftritt dürfen da Zeilen entfernt werden nach Lust und Laune.

Aber lass uns das mal nicht weiter hier austreten. Sieh bitte einfach Kritik nicht als persönliche Kritik an sondern das ist nunmal ein Forum in dem ich ein paar Nachrichten pro Tag schreibe und nicht jedes einzelne Wort vorher abwäge. Und ich bin ein Typ der lieber 1x zuviel auf etwas hinweist als zu wenig. Was dann wohl leider gelegentlich - wie hier gerade - dazu führt dass ich halt jemand auf die Zehen trete.

Das ganze Deutsch hier wird peinlich :)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

right, this forum is english so let's talk english... :lol:

well, the code compiles, it runs and it contains the error, and also I deleted many code that realy doesn't matter (from the functions at the bottom, and even hybrid thought it could be located there)... ;)

I realy don't see what's wrong with this code... :shock:
When I had the problem it was not obvious where the error is located, because it also could be that there are some bugs with some other GUI elements (like the focus bug) that could caused this, so it's always a good idea to post the whole creation of all gui elements in such a case... ;)
and there is realy not much more than that in this code...

there are many other posts that shows complete programs that's realy not neccesary and many codes are bad or even not formatted and commented and some are even not inside the code tags...

But I will agree with you if you can show me where this code is realy bad for posting here (I realy want to know) !!! ;)
And if you don't want to read more than 5 lines of code, than simply don't do so (no one else does so, I think)... :lol:
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

ist nicht sprecke deutsch.

sprecke inglish.

habla en ingles, por favor.

takalam inglisi, min fadlik.
Last edited by dlangdev on Thu Feb 07, 2008 8:35 pm, edited 2 times in total.
Image
Post Reply