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...
Even more strange I can click where ever I want to move the dialog (also with click outside the dialog) !!!
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
}