# Simple ComboBox Tick Replacement

**URL:** <https://forum.juce.com/t/simple-combobox-tick-replacement/17023>\
**Category:** General JUCE discussion\
**Created:** [March 27, 2016, 5:03am UTC](https://forum.juce.com/t/simple-combobox-tick-replacement/17023 "2016-03-27T05:03:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bdawson](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/bdawson/32/14755_2.png) [@bdawson](https://forum.juce.com/u/bdawson)\
**Post date:** [March 27, 2016, 5:03am UTC](https://forum.juce.com/t/simple-combobox-tick-replacement/17023/1 "2016-03-27T05:03:15Z")

</div>

Hey jucers,

&nbsp;

I'd like to replace the 'tick' on the ComboBox class with a custom image.

I have attempted to add a StringArray list to a Popup menu, and -\>addItems to that popupmenu including the image I wanted to use, and then passed that popupmenu to the comboBox using the .addItemsToMenu function. However considering this is a virtual function, it doesn't seem to be the right approach.

Thoughts on the most straightforward way of doing this?

&nbsp;

Thanks so much,  
B

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [March 27, 2016, 10:28am UTC](https://forum.juce.com/t/simple-combobox-tick-replacement/17023/2 "2016-03-27T10:28:06Z")

</div>

Have a look at the "Look and Feel" classes:

https://www.juce.com/doc/structComboBox\_1\_1LookAndFeelMethods

You inherit this, override the methods you want to change (i.e. https://www.juce.com/doc/structComboBox\_1\_1LookAndFeelMethods#ae43e629153160f3ff1ddacbad9430fb7 ). Then you set an instance of your look and feel class either to that component or to the parent component as defaultLookAndFeel.

You can use the original drawing code as a starting point: https://github.com/julianstorer/JUCE/blob/master/modules/juce\_gui\_basics/lookandfeel/juce\_LookAndFeel\_V2.cpp#L1114

HTH, daniel

---

<div class="post-metadata">

**Author:** ![bdawson](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/bdawson/32/14755_2.png) [@bdawson](https://forum.juce.com/u/bdawson)\
**Post date:** [March 27, 2016, 6:55pm UTC](https://forum.juce.com/t/simple-combobox-tick-replacement/17023/3 "2016-03-27T18:55:26Z")

</div>

Thanks for the response Daniel,

&nbsp;

The tick is part of the popup menu class, which is inherited by the comboBox class.&nbsp;Would I set a popup menu lookAndFeel and set that to the ComboBox as well? I spent a bit of time on it yesterday and it seems to go beyond a typical LookAndFeel use case.

&nbsp;

If anyone else reading this has replaced the 'tick' graphic in the ComboBox class, please let me know your method of doing so.

&nbsp;

Thanks,  
B

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [March 27, 2016, 7:46pm UTC](https://forum.juce.com/t/simple-combobox-tick-replacement/17023/4 "2016-03-27T19:46:00Z")

</div>

Ok, I see. The Combobox doensn't inherit the popup menu, but it is created in the showPopup method: https://www.juce.com/doc/classComboBox#a46d401e92f606ef7ffa081d5e0bdb609

> This is virtual so that you can override it with your own custom popup mechanism if you need some really unusual behaviour.

But the popup menu takes the default look and feel, so either alter that one, or override this: https://github.com/julianstorer/JUCE/blob/536ca6cedf7b3e373778f653da9e0c1a8e3438b2/modules/juce\_gui\_basics/widgets/juce\_ComboBox.cpp#L531

```
void ComboBox::showPopup() 
{ 
    PopupMenu menu; 
    menu.setLookAndFeel (&getLookAndFeel()); 
    addItemsToMenu (menu); 
    menu.showMenuAsync (PopupMenu::Options().withTargetComponent (this) 
                                            .withItemThatMustBeVisible (getSelectedId()) 
                                            .withMinimumWidth (getWidth()) 
                                            .withMaximumNumColumns (1) 
                                            .withStandardItemHeight (label->getHeight()), 
                        ModalCallbackFunction::forComponent (comboBoxPopupMenuFinishedCallback, this)); 
}
```

I just followed getLookAndFeel(), I think you can simply alter the void LookAndFeel\_V2::drawPopupMenuItem as well, the drawing is done here:

https://github.com/julianstorer/JUCE/blob/536ca6cedf7b3e373778f653da9e0c1a8e3438b2/modules/juce\_gui\_basics/lookandfeel/juce\_LookAndFeel\_V2.cpp#L977

So it's the same look and feel you set for the ComboBox...

Good Luck,

daniel

&nbsp;

---

<div class="post-metadata">

**Author:** ![bdawson](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/bdawson/32/14755_2.png) [@bdawson](https://forum.juce.com/u/bdawson)\
**Post date:** [March 28, 2016, 5:21pm UTC](https://forum.juce.com/t/simple-combobox-tick-replacement/17023/5 "2016-03-28T17:21:00Z")

</div>

Thanks for taking the time to look into this Daniel. I will let you know my results. :)

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [March 28, 2016, 6:40pm UTC](https://forum.juce.com/t/simple-combobox-tick-replacement/17023/6 "2016-03-28T18:40:45Z")

</div>

I'm looking forward to it. I'm just starting to style my plugin, so reading how the details of look and feel work was not that altruistic at all ;-)

---

<div class="post-metadata">

**Author:** ![mrkdji](https://avatars.discourse-cdn.com/v4/letter/m/51bf81/32.png) [@mrkdji](https://forum.juce.com/u/mrkdji)\
**Post date:** [May 8, 2023, 9:15pm UTC](https://forum.juce.com/t/simple-combobox-tick-replacement/17023/7 "2023-05-08T21:15:37Z")

</div>

For posterity: inherit from LookAndFeel and override getTickShape

```c++
class MyLookAndFeel : public juce::LookAndFeel_V4
{
    juce::Path getTickShape(float height) override;
};

```

---

<div class="post-metadata">

**Author:** ![nfect](https://avatars.discourse-cdn.com/v4/letter/n/a6a055/32.png) [@nfect](https://forum.juce.com/u/nfect)\
**Post date:** [May 11, 2023, 8:25pm UTC](https://forum.juce.com/t/simple-combobox-tick-replacement/17023/8 "2023-05-11T20:25:42Z")

</div>

but I believe the OP needed to replace it with an image
