IrrEventManager

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki

Postby milkshakeman » Wed Dec 30, 2009 3:40 pm

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());

}
milkshakeman
 
Posts: 27
Joined: Mon Aug 14, 2006 12:36 pm

Postby kh_ » Fri Jan 01, 2010 12:12 am

[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: 75
Joined: Fri May 19, 2006 4:29 pm

Postby kh_ » Fri Jan 01, 2010 1:52 am

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.
kh_
 
Posts: 75
Joined: Fri May 19, 2006 4:29 pm

Postby milkshakeman » Mon Jan 04, 2010 1:38 pm

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.
milkshakeman
 
Posts: 27
Joined: Mon Aug 14, 2006 12:36 pm

Re: IrrEventManager

Postby kh_ » Wed Feb 01, 2017 1:21 am

I finally got back into Irrlicht and updated this. Hope somebody finds it useful.
kh_
 
Posts: 75
Joined: Fri May 19, 2006 4:29 pm

Re: IrrEventManager

Postby AReichl » Wed Feb 01, 2017 8:24 am

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

Did you mean
#include "CEventManager.h" ?
AReichl
 
Posts: 229
Joined: Wed Jul 13, 2011 2:34 pm

Re: IrrEventManager

Postby kh_ » Wed Feb 01, 2017 12:45 pm

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

Re: IrrEventManager

Postby kh_ » Wed Feb 01, 2017 1:25 pm

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: 75
Joined: Fri May 19, 2006 4:29 pm

Previous

Return to Project Announcements

Who is online

Users browsing this forum: No registered users and 1 guest

cron