# Label TextEditor::setSelectAllWhenFocused(true) on bug?

**URL:** <https://forum.juce.com/t/label-texteditor-setselectallwhenfocused-true-on-bug/7518>\
**Category:** General JUCE discussion\
**Created:** [September 29, 2011, 3:37pm UTC](https://forum.juce.com/t/label-texteditor-setselectallwhenfocused-true-on-bug/7518 "2011-09-29T15:37:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexsmode](https://avatars.discourse-cdn.com/v4/letter/a/c68b51/32.png) [@alexsmode](https://forum.juce.com/u/alexsmode)\
**Post date:** [September 29, 2011, 3:37pm UTC](https://forum.juce.com/t/label-texteditor-setselectallwhenfocused-true-on-bug/7518/1 "2011-09-29T15:37:17Z")

</div>

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

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

into the previous Juce version

```auto

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

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

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [September 29, 2011, 3:57pm UTC](https://forum.juce.com/t/label-texteditor-setselectallwhenfocused-true-on-bug/7518/2 "2011-09-29T15:57:27Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![alexsmode](https://avatars.discourse-cdn.com/v4/letter/a/c68b51/32.png) [@alexsmode](https://forum.juce.com/u/alexsmode)\
**Post date:** [September 30, 2011, 7:47am UTC](https://forum.juce.com/t/label-texteditor-setselectallwhenfocused-true-on-bug/7518/3 "2011-09-30T07:47:27Z")

</div>

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

```auto
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();
    }
}
```
