[no bug]CGUIMenu (the bar)

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
chronologicaldot
Competition winner
Posts: 688
Joined: Mon Sep 10, 2012 8:51 am

[no bug]CGUIMenu (the bar)

Post by chronologicaldot »

I set up a simple menu bar and couldn't get it to respond to EGET_MENU_ITEM_SELECTED, even though it responded to the focus events, but I found this in CGUIMenu.cpp, lines 155-166:

Code: Select all

 
            case EMIE_LMOUSE_LEFT_UP:
            {
                core::position2d<s32> p(event.MouseInput.X, event.MouseInput.Y);
                if (!AbsoluteClippingRect.isPointInside(p))
                {
                    s32 t = sendClick(p);
                    if ((t==0 || t==1) && Environment->hasFocus(this))
                        Environment->removeFocus(this);
                }
 
                return true;
            }
 
It checks if the point is outside of the clipping rectangle. I think it's supposed to check if it's inside, no?
I'm using irrlicht 1.8.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: CGUIMenu (the bar)

Post by CuteAlien »

It checks for when it should remove the focus. And it should do that when the user clicks outside. So that part seems correct.

If you need an example for menues check gui_menu_test.cpp at https://code.google.com/p/irr-playgroun ... rce/browse
That does pretty much everything you can do with menues.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
chronologicaldot
Competition winner
Posts: 688
Joined: Mon Sep 10, 2012 8:51 am

Re: [no bug]CGUIMenu (the bar)

Post by chronologicaldot »

Thanks!
You're example worked. I discovered I hadn't made the OnEvent virtual in my event receiver class, but for some odd reason, the OnEvent function was called for everything else, so that might not be it either.
Anything look wrong with this?:

Code: Select all

 
bool GuiControl::OnEvent(const SEvent &event)
{
    if ( event.EventType == irr::EET_GUI_EVENT )
        return OnGuiEvent(event);
 
    return false;
}
 
bool GuiControl::OnGuiEvent( const SEvent& event )
{
    IGUIContextMenu* menu;
    EGuiElemId commandId; // my enum
 
    switch ( event.GUIEvent.EventType )
    {
    case EGET_MENU_ITEM_SELECTED:
    // code never reached (I used cout to check)
 
// etc.
 
The menu showed up, responded to focus events, but no EGET_MENU_ITEM_SELECTED. Bizarre.
Anyways - I've replaced it with a bar and buttons that do work.

Sorry to bother you.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: [no bug]CGUIMenu (the bar)

Post by CuteAlien »

The part you posted looks fine to me.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply