ofxUIDropDownList event problem

The ofxUI addon features a drop-down menu. Unfortunately it does not only trigger events if the user selects an item. It also triggers events of ui elements positioned underneath the menu. See: https://github.com/rezaali/ofxUI/issues/68

Has anyone figured out a solution?

Thanks,
Armin

simplest thing to do would be to keep a status variable (like a bool) that keeps track of when you have a menu open, and use it to ignore events from any other UI element or revert them to previous values. it’s a nasty hack but it works. another way would be to keep all of your UI elements in a vector and disable all of the ones that are not the active/open menu.

1 Like

This is exactly what I did, but this workaround raises some other issues:

  • By disabling all other GUI elements the dropdown menu turns into some sort of modal window. This is not how dropdown menus usually work. If I decide to just disable elements which are positioned underneath the menu, things get complicated the moment I use menus of variable sizes.
  • If autoClose is activated a simple status variable won’t help. After selecting an element the menu will close, the status variable will change and the following buttonUp event will trigger something. I could try to play around with the getValue() method of the widgets, but I think I’m barking up the wrong tree…

I thought about ditching ofxUIDropDownList and make my own “disclosure widget” instead: just one ofxUIToggle which disappears and shows some radio buttons when pressed. After one radio button has been pressed, they disappear and the toggle appears again.

Unfortunately the canvas doesn’t rearrange its elements when widgets are made invisible or get removed. Is there an easy way to make it recalculate the widget positions? Has anyone done this before?

apparently not. for future reference: here’s a nongeneralizable quickfix: