FR: PopupMenu::Options make number of columns adjustable


Right now you can only set a maximum number of columns, and columns only get created if the vertical space is exhausted.

We would like to set a fixed number of items that make up one column, or set a fixed number of columns, to create a much better user experience.

This works particular well if you have not too many similar choices.

Here is an example from Nexus2:


The same can be applied to filter-types (lp6, lp12, lp24, hp6, hp12, hp24 etc.).

It also nicely shows the relationships between the different values.


After-weekend bump.


Can I please get a reply? Anything at all? @jules @fabian @ed95 @t0m


I’ve added something to do that - should be on develop soon…


Just an idea: the most flexible solution would be to add a function similar to addSeparator = addColumnBreak.


Well, if I was going to design it again from scratch then using FlexBox would be ideal. In this case though it was very easy to add a minimum num columns.


I think flexbox would be overkill, as you possibly only need 3-4 columns max. Anything more would mean that there are too many choice and a different input method should maybe be used altogether :wink:


Just downloaded the latest develop and it works like a charm. Thank you.

Only complaint: there is no visual divider between the columns. See my screenshot at the beginning of this post for reference.

Thanks :slight_smile:


Well, you can do that with your own L+F, if that’s what you’re going for.


I don’t really see how. How can I detect in “drawPopupMenuItem” that this item is part of a multi-column menu? Or that it’s not the last column, so it doesn’t have to draw a line on the right hand side?

Maybe I’m missing something obvious here?


Hmm, I guess there’s not enough info in the callback to know that.

Actually, given that you’re forcing a known number of columns, it might be better to draw the lines in the drawPopupMenuBackground call instead, where you know the overall size so it’s easy to figure out.


Yes, but I’m not always forcing multiple columns. Since the drawPopupMenuBackground doesn’t get any additional information either (only width and height), I can’t dynamically detect how many columns are used. I would need to create one custom LookAndFeel class for each number of columns…