Label TextEditor::setSelectAllWhenFocused(true) on bug?


#1

My custom Label overload Label::createEditorComponent to setSelectAllWhenFocused(true) on returned TextEditor.
Previously on with juce 1.52 it work correctly; In juce 1.53 it does’nt work anymore :
Popup TextEditor text is not selected, the caret is at the end of the text.

Perhaps my calling code should be refactored to a newer Juce approach…
To fix this issue I revert the line

void Label::showEditor()
...
enterModalState (false);
...

into the previous Juce version


void Label::showEditor()
...
enterModalState (); // takeKeyboardFocus is true by default
...

Thank you in advance for a proper way to resolve this issue.


#2

I changed it because I didn’t want the Label to get the focus, I wanted the editor itself to get it. That’s why it says:

enterModalState (false); editor->grabKeyboardFocus(); } }

Perhaps you’re looking at an older version than this, without the grabKeyboardFocus call?


#3

It’s strange, my previous version of Juce
git a983bb1300e6ade0e475d163dc035aa61cde28a2
31 Aug 2009 160852
do the editor->grabKeyboardFocus() too :

void Label::showEditor()
{
    if (editor == 0)
    {
        addAndMakeVisible (editor = createEditorComponent());
        editor->setText (getText(), false);
        editor->addListener (this);
        editor->grabKeyboardFocus();
        editor->setHighlightedRegion (0, text.length());
        editor->addListener (this);

        resized();
        repaint();

        editorShown (editor);

        enterModalState();
        editor->grabKeyboardFocus();
    }
}