# BubbleMessageComponent text colour

**URL:** <https://forum.juce.com/t/bubblemessagecomponent-text-colour/45188>\
**Category:** General JUCE discussion\
**Created:** [March 24, 2021, 1:48pm UTC](https://forum.juce.com/t/bubblemessagecomponent-text-colour/45188 "2021-03-24T13:48:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [March 24, 2021, 1:48pm UTC](https://forum.juce.com/t/bubblemessagecomponent-text-colour/45188/1 "2021-03-24T13:48:57Z")

</div>

BubbleMessageComponent does

```
void BubbleMessageComponent::paintContent (Graphics& g, int w, int h)
{
    g.setColour (findColour (TooltipWindow::textColourId));

```

except that it won’t use this colour as it uses the colour in the TextLayout

Similar issue that was fixed here

> [@Cannot change AlertWindow text colour](https://forum.juce.com/t/cannot-change-alertwindow-text-colour/7948):
>
> Hi. Changing the colour of AlertWindow::textColourId does not reflect on the text colour in the AlertWindow. These are the lines in LookAndFeel:drawAlertBox() which are responsible for the drawing of the text: [code]g.setColour (alert.findColour (AlertWindow::textColourId)); textLayout.draw (g, Rectangle (textArea.getX() + iconSpaceUsed, textArea.getY(), textArea.getWidth() - iconSpaceUsed, textArea.getHeight()).toFloat());[/code] Is it possible that TextLayout::draw no longer affects th…

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [March 24, 2021, 2:06pm UTC](https://forum.juce.com/t/bubblemessagecomponent-text-colour/45188/2 "2021-03-24T14:06:51Z")

</div>

Given that `showAt` takes an `AttributedString`, it might be surprising (and may cause existing UIs to render incorrectly) if the component overrode the colour set on this string. That being said, it does look like this was the original intention…

The AlertWindow case is a bit different, because the interface only accepts `String` instances, so it’s completely reasonable to expect the box to render text using colours set in its LnF.

In the absense of a really compelling argument to modify BubbleMessageComponent, I think I’d recommend writing a tiny function which wraps `BubbleMessageComponent::showAt` and which internally constructs an `AttributedString` of an appropriate colour.

---

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [March 24, 2021, 2:51pm UTC](https://forum.juce.com/t/bubblemessagecomponent-text-colour/45188/3 "2021-03-24T14:51:12Z")

</div>

yep, probably just need to clean the paintContent func.  
At first, in order to know how the component worked, I checked the paintContent content and didn’t understand why my manual set of TooltipWindow::textColourId wasn’t working.  
I didn’t remember that attributed string allowed to set the colour
