elementToFront' question


#1

in jucer,display “send to back” and “bring to front” for component,my question is:for two components,such as TextEditor ,TextButton,can select them for it to work well------one back ,one front.But for Text------ " g.drawText (L"Your text goes here",
76, 84, 200, 30,
Justification::centred, true);"
“Your text goes here” is not front with TextButton.why?Thank you.
others,how to analyse "FrontOrBackElementAction " and “moveElementZOrder”?,as follows
//-------------------------------------------------------------------------------------------------------------------------------
void PaintRoutine::elementToFront (PaintElement* element, const bool undoable)
{
if (element != 0 && elements.contains (element))
{
if (undoable)
perform (new FrontOrBackElementAction (element, -1), “Move elements to front”);
else
moveElementZOrder (elements.indexOf (element), -1);
}
}

class FrontOrBackElementAction : public PaintElementUndoableAction
{
public:
FrontOrBackElementAction (PaintElement* const element, int newIndex_)
: PaintElementUndoableAction (element),
newIndex (newIndex_)
{
oldIndex = routine.indexOfElement (element);
}

bool perform()
{
    showCorrectTab();

    PaintElement* e = routine.getElement (oldIndex);
    routine.moveElementZOrder (oldIndex, newIndex);
    newIndex = routine.indexOfElement (e);
    return true;
}

bool undo()
{
    showCorrectTab();
    routine.moveElementZOrder (newIndex, oldIndex);
    return true;
}

private:
int newIndex, oldIndex;
};

void PaintRoutine::moveElementZOrder (int oldIndex, int newIndex)
{
jassert (elements [oldIndex] != 0);

if (oldIndex != newIndex && elements [oldIndex] != 0)
{
    elements.move (oldIndex, newIndex);
    changed();
}

}


#2

I don’t quite get the question as I don’t use Jucer but g.drawText is drawn to whatever graphics component it is set to. I presume this is on the main component background in your example, so components such as TextBoxs will be drawn over it. Use Label instead as this is a component can be brought to the front.