Combobox Changing Dropdown Rectangle Width

I have the following dropdown menu I am working on:
image

I am trying to change the dropdown menu width.

I am overwriting the drawPopupMenuItem() and drawComboBox() methods from the LookAndFeel but I cannot seem to locate anything in these methods I can use to change the width of the rectangle that drops down. Any suggestions?

Checkout juce::ComboBox::LookAndFeelMethods::getOptionsForComboBoxPopupMenu():

https://docs.juce.com/master/structComboBox_1_1LookAndFeelMethods.html#a05d7d621d44d6aaa87f6688fc58def2a

Which returns a juce::PopupMenu::Options on which is the method withTargetScreenArea() where you can pass custom bounds for the bounds of the popup.

1 Like

Thanks for that @ImJimmi

image

I can change the width of the rectangle by changing the .withMinimumWidth () argument value in that getOptionsForComboBoxPopupMenu() method but now I need to move that rectangle along the x-axis.

Any suggestions on how to do that?

Finally figured it out!

If you change the .withTargetScreenArea() argument in getOptionsForComboBoxPopupMenu() to include a rectangle of the combox, you can translate that by a small amount to shift the rectangle drop-down. You need to use getScreenBounds() to get that rectangle which every Combobox inherits from the Component class. JUCE can get very counter-intuitive sometimes in my opinion but all good now!