IrrEventManager v1.8.4 FINAL!

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
milkshakeman
Posts: 27
Joined: Mon Aug 14, 2006 12:36 pm

Post by milkshakeman »

Is it possible I have a problem with a context menu? (the one that disappears automatically, after you clicked on a menu item) created with addContextMenu.

I assign the handler function like I would with a normal menu, and if I use the normal menu, it works. But with a menu created with addContextMenu (for example after a right-click) the event handler function is not called?

Code: Select all

void CContextMenu::popup(int x, int y)
{
    IGUIContextMenu* Menu = Guienv->addContextMenu(rect<s32>(x,y,x,y));
    Menu->addItem(L"Do Something");
    addGuiEventT(em,EGET_MENU_ITEM_SELECTED,Menu,&CContextMenu::MenuDoSomething_Handler,this,this);
}
bool  CContextMenu::MenuDoSomething_Handler(const SEvent&  ev,IEventRecEx* rec)
{
    stringw messageText = L"test message";
    stringw caption = L"test caption";

    /// create modal message box with the text
	IGUIWindow * w = Guienv->addMessageBox(caption.c_str(), messageText.c_str());

}
kh_
Posts: 78
Joined: Fri May 19, 2006 4:29 pm

Post by kh_ »

[Edit: After looking at the source, in Irrlicht, -1 is the default argument for the id.So you shouldn't need to pass it. ]

when you call :

Code: Select all

void CContextMenu::popup(int x, int y)
{
    Menu->addItem(L"Do Something"); 
Try it with -1 at the end:

Code: Select all

void CContextMenu::popup(int x, int y)
{
    Menu->addItem(L"Do Something",-1); 
Last edited by kh_ on Fri Jan 01, 2010 3:05 am, edited 1 time in total.
kh_
Posts: 78
Joined: Fri May 19, 2006 4:29 pm

Post by kh_ »

I'm not sure what's going on. At first it looked like it needed the above but now this is working.

Code: Select all

class CContextMenu1
{

bool  MenuDoSomething_Handler(const SEvent&  ev,IEventRecEx* rec)
{
    stringw messageText = L"test message";
    stringw caption = L"test caption";
    /// create modal message box with the text
    IGUIWindow * w = guienv->addMessageBox(caption.c_str(), messageText.c_str());

}

public:
void popup(int x=100, int y=100)
{
    IGUIContextMenu* Menu = guienv->addContextMenu(rect<s32>(x,y,x,y));
    Menu->addItem(L"Do Something");
    addGuiEventT(em,EGET_MENU_ITEM_SELECTED,Menu,&CContextMenu1::MenuDoSomething_Handler,this,this);
}

};

CContextMenu1 cm1;




 if (em->mouseClick(EMB_R))
            {
                cm1.popup();
            }
If you still can't get it working try posting a simple but complete example that doesn't work for me to look at.

After looking at the source, in Irrlicht, -1 is the default argument for the id.So you shouldn't need to pass it.
milkshakeman
Posts: 27
Joined: Mon Aug 14, 2006 12:36 pm

Post by milkshakeman »

Ok, in the mean time I reworked my GUI so I did not have to use a context menu. But it is not a bad thing because now it is even more user-friendly. :D
But if you say it should work, I must have done something wrong. (the code example was a very simplified version of the real code). I will do a little test this evening, and if it fails I'll post it here.
kh_
Posts: 78
Joined: Fri May 19, 2006 4:29 pm

Re: IrrEventManager

Post by kh_ »

I finally got back into Irrlicht and updated this. Hope somebody finds it useful.
AReichl
Posts: 270
Joined: Wed Jul 13, 2011 2:34 pm

Re: IrrEventManager

Post by AReichl »

In EventManager.h you wrote
#include "EventManager.h"
but thats including itself.

Did you mean
#include "CEventManager.h" ?
kh_
Posts: 78
Joined: Fri May 19, 2006 4:29 pm

Re: IrrEventManager

Post by kh_ »

Thanks, I uploaded the wrong file, I'll fix it today
kh_
Posts: 78
Joined: Fri May 19, 2006 4:29 pm

Re: IrrEventManager

Post by kh_ »

Ok.you were right on that. The file SEventRecEX.h was only for the tests so there was no effect on the manager library. Since CEventManager.h was already included SEventRecEX.h there was no point in having EventManager.h since its purpose was to save from including both headers into your program. The simple fix was to delete EventManager.h and rename SEventRecEX.h to EventManager.h .
Hope that made sense.
If there was a file named IEventEx.h in yours it could be deleted.
Thanks for pointing that out, I'm suprised there were no errors or warnings compiling it.
kh_
Posts: 78
Joined: Fri May 19, 2006 4:29 pm

Re: IrrEventManager Major changes!

Post by kh_ »

Eventmanager was just updated with big changes/ improvements.
Post Reply