[ofxUI] UI Transitions are not doing what I expect

Hello everyone,

I have begun using ofxUI in my program, because it seems much better than the built in ofxGui. I have made a set of UI panels that transition to one another when I press buttons (aka a ‘return to main menu’ button hides the current UI and shows the ‘Main Menu’ UI). This seems to work fine for the first time I transition between two panels, but when I try to go back again, it flickers on and of, and then I have to click a second time to actually transition. Does anyone have any idea why this is happening? I am just doing a simple gui->toggleVisible() on the GUI to show and hide each panel. by the way, each panel is a separate ofxUISuperCanvas.

Thanks for any help.

EDIT: Link to a binary example: https://www.mediafire.com/?nr5frrogdgnadaz

Hi,
Hard to guess without the code, but perhaps your button hit detection is not good? A button fire an event twice, on mouse press and on mouse release. Do you ckeck this in the event callback function? Something like

ofxUILabelButton * theBtn;
theBtn = aGUI->addLabelButton( "Return to main menu", false );

void testApp::onGUIEvent( ofxUIEventArgs & e ) {
    if( e.widget == theBtn ) { // the button fire the event
        if( !theBtn->getValue() ) { // swap UI only if the button is released
            // Swap canvas here
        }
    }

@lilive Thanks! This fixed the problem I was having. I didn’t realize the buttons transmitted both of their states.