[SOLVED]How to close a Menubar if capture is lost?

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

osbios
Just popping in
Just popping in
Posts: 13
Joined: Thu Jul 21, 2011 20:34

[SOLVED]How to close a Menubar if capture is lost?

Postby osbios » Tue Jan 29, 2013 19:05

I like my Menubar to close if you click on anythink outside the menu. Like it is the default with many other GUIs.
I have the event function running when this happens, now I only need to find a function to close the CEGUI::Menubar.
Is there a function/way to do this?

Code: Select all

27/01/2013 20:04:21 (Std)    ---- Version 0.7.5 (Build: Apr 28 2012 GNU/Linux g++ 4.6.3 64 bit) ----
27/01/2013 20:04:21 (Std)    ---- Renderer module is: CEGUI::OpenGLRenderer - Official OpenGL based 2nd generation renderer module.  TextureTarget support enabled via FBO extension. ----
27/01/2013 20:04:21 (Std)    ---- XML Parser module is: CEGUI::ExpatParser - Official expat based parser module for CEGUI ----
27/01/2013 20:04:21 (Std)    ---- Image Codec module is: DevILImageCodec - Official DevIL based image codec ----
27/01/2013 20:04:21 (Std)    ---- Scripting module is: None ----
Last edited by osbios on Tue Jan 29, 2013 22:25, edited 1 time in total.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: How to close a Menubar if capture is lost?

Postby Kulik » Tue Jan 29, 2013 19:09

Are you absolutely sure you mean Menubar?

You probably want PopupMenu and this:
http://www.cegui.org.uk/docs/current/cl ... 9f4561ec3a

osbios
Just popping in
Just popping in
Posts: 13
Joined: Thu Jul 21, 2011 20:34

Re: How to close a Menubar if capture is lost?

Postby osbios » Tue Jan 29, 2013 20:34

Yes, I mean the Menubar. Like this:

Image

I would like any open Menu to close if I click in the grey array.

What would be the most elegant way to call closePopupMenu() on every PopupMenu except manually do it for each single one?

osbios
Just popping in
Just popping in
Posts: 13
Joined: Thu Jul 21, 2011 20:34

Re: How to close a Menubar if capture is lost?

Postby osbios » Tue Jan 29, 2013 22:25

Solved it:

Code: Select all

menubar->subscribeEvent(CEGUI::Window::EventDeactivated,
        CEGUI::Event::Subscriber(&CeguiIcaf::inputCaptureLost, this));


Code: Select all

bool CeguiIcaf::inputCaptureLost(const CEGUI::EventArgs& e)
{
    const ActivationEventArgs &f = dynamic_cast<const ActivationEventArgs&>(e);

    CEGUI::Menubar *m = dynamic_cast<CEGUI::Menubar*>(f.window);

    for (int i=0; i < m->getChildCount(); ++i)
    {
       CEGUI::MenuItem* child = dynamic_cast<MenuItem*>( m->getChildAtIdx( i ) );
       child->closePopupMenu();
    }

    return true;
}


Return to “Help”

Who is online

Users browsing this forum: No registered users and 6 guests