Page 3 of 3

Posted: Wed Dec 30, 2009 3:40 pm
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());

}

Posted: Fri Jan 01, 2010 12:12 am
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); 

Posted: Fri Jan 01, 2010 1:52 am
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.

Posted: Mon Jan 04, 2010 1:38 pm
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.

Re: IrrEventManager

Posted: Wed Feb 01, 2017 1:21 am
by kh_
I finally got back into Irrlicht and updated this. Hope somebody finds it useful.

Re: IrrEventManager

Posted: Wed Feb 01, 2017 8:24 am
by AReichl
In EventManager.h you wrote
#include "EventManager.h"
but thats including itself.

Did you mean
#include "CEventManager.h" ?

Re: IrrEventManager

Posted: Wed Feb 01, 2017 12:45 pm
by kh_
Thanks, I uploaded the wrong file, I'll fix it today

Re: IrrEventManager

Posted: Wed Feb 01, 2017 1:25 pm
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.

Re: IrrEventManager Major changes!

Posted: Mon Feb 12, 2018 1:42 am
by kh_
Eventmanager was just updated with big changes/ improvements.