TextEditor colour incorrectly initialised in AlertWindow

given the current code for AlertWindow::addTextEditor()

void AlertWindow::addTextEditor (const String& name,
const String& initialContents,
const String& onScreenLabel,
const bool isPasswordBox)
    TextEditor* ed = new TextEditor (name, isPasswordBox ? getDefaultPasswordChar() : 0);
    ed->setSelectAllWhenFocused (true);
    ed->setEscapeAndReturnKeysConsumed (false);
    textBoxes.add (ed);
    allComps.add (ed);
    ed->setColour (TextEditor::outlineColourId, findColour (ComboBox::outlineColourId));
    ed->setFont (getLookAndFeel().getAlertWindowMessageFont());
    ed->setText (initialContents);                    // !!!! inital text is set here
    ed->setCaretPosition (initialContents.length());
    addAndMakeVisible (ed);                           // !!!! the editor is added to the window here
    textboxNames.add (onScreenLabel);
    updateLayout (false);

as I have mentioned in the comments added after the "!!!!", the initial text for the editor is set prior to its addition as a child of the window.

This means that when setText() is called, the colour assigned to the starting chunk of text in the editor is always taken from the default look and feel and not from the AlertWindow or its LookAndFeel, if they had a custom one set.

The correct order of those operation should be invered, so that when setText() is called, the editor is already a child of AlertWindow and all the findColour() calls will walk the correct and final hierarchy.


Thanks, I'll switch it around!