Contextual menu problems

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
Didine
Posts: 19
Joined: Wed Aug 24, 2005 1:22 pm
Location: France
Contact:

Contextual menu problems

Post by Didine »

I have 2 problems with a contextual menu which is displayed by the right click above a bsp map with fps camera.
1) The first pb is that the menu cannot be displayed more than one time. Because an second call to the menu causes a crash of the program.
2) The second pb is that the event reveiver doesn't work on it.

This is the code event

Code: Select all

if (event.EventType == EET_MOUSE_INPUT_EVENT) {
          switch(event.MouseInput.Event)
          {
            case EMIE_RMOUSE_LEFT_UP: { // the contextual menu is displayed  by the right click
                     camera->setInputReceiverEnabled(false); 
                     cameraOFF = true;
                     device->getCursorControl()->setVisible(true);    
                     MenuCont->setVisible(true);
                  } //case
            } // switch                                       
      }
	if (event.EventType == EET_GUI_EVENT) {
		  s32 id = event.GUIEvent.Caller->getID();
		  IGUIEnvironment* env = device->getGUIEnvironment();
		  switch(event.GUIEvent.EventType)
		  {   
              case EGET_MENU_ITEM_SELECTED: { // a menu item was clicked
				if (id == 101) { // contextuel menu -> quit
                  finProg = true; 
                  break;
                }  
				if (id == 102) { // contextual menu -> cancel
                  camera->setInputReceiverEnabled(true); 
                  break;
(...)
and in main procedure

Code: Select all

MenuCont = env-> addContextMenu(rect< s32 > (Xres/2-20,Yres/2-20,Xres/2+20,Yres/2+100));
MenuCont-> addItem (L"Quit",101,true,false ); 
MenuCont-> addItem (L"Cancel", 102, true, false );  
MenuCont->setVisible(false); 
What's wrong ?
Post Reply