Popup menu doesn't work properly


#1

Good day. Problem is that I’m using SimpleListBox and SimpleListBoxModel. In model when user clicks item I show popup menu.
But what is intersted that menu is showed in Debug mode, but isn’t visible in Realese mode. Any ideas?


#2

Also. If list isn’t enabled, but I changed numRow in model and invoked setRowHeight, than list’s children are enabled. :smiley:


#3

That’s a very misleading topic title - the menus do work properly. I’d bet this is just an uninitialised variable in your code.

And it’s not possible for a child component to be enabled when one of its parents is disabled, so don’t see how the rows could possibly be enabled. Are you accidentally enabling the list? Or just drawing them incorrectly? You realise that being disabled doesn’t stop a component from getting mouse clicks, so you’d still have to deal with that yourself by checking isEnabled() in your event handler.


#4

Ok. Sorry for misleading topic.
But I’m not clear with your post.
First, about popup menu. Debug works, Realese doesn’t. No changes in codes. What variable is uninitialized.
About second.

model = new MyListBoxModel();
addAndMakeVisible(list = new RestrictsList(model));
list->setOutlineColour (Colours::black.withAlpha (0.5f), 1);
list->setEnabled(false);
model->addActionListener(this);
model->setId(5);
list->setRowHeight(22);

After this code model receives itemClicks.


#5

Popup menus work perfectly well in release mode. Normally when something is different in a release build, it’s because you’ve not initialised a variable. In debug mode the compiler fills uninitialised variables with cdcdcdcd to help spot mistakes, but in release it doesn’t.

And like I just explained, disabling a list doesn’t prevent mouse clicks from reaching it. The enablement is a property that’s there for your component to use in whatever way is appropriate - it doesn’t automatically stop the component getting events, because you might need them for some custom behaviour.


#6

Thanks. Maybe you right with initializing.
About enabling, model doesn’t have accesses to list. How it could understand that list isn’t enabled. When list is disabled highlighting of items works.


#7

Hmm… yes, I guess for the SimpleListBox you might be right: maybe the enablement checks should go in the base class. I’ll have a look…


#8

Jules, thanks. There was problem with uninitialized variable. I forgot about small enable flag, which I added in model to deny posssibility of popup menu.


#9