# Highlight text inside a textInput component

**URL:** <https://forum.kirupa.com/t/highlight-text-inside-a-textinput-component/290928>\
**Category:** flash\
**Created:** [June 22, 2009, 12:25pm UTC](https://forum.kirupa.com/t/highlight-text-inside-a-textinput-component/290928 "2009-06-22T12:25:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kiwiki098](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@kiwiki098](https://forum.kirupa.com/u/kiwiki098)\
**Post date:** [June 22, 2009, 12:25pm UTC](https://forum.kirupa.com/t/highlight-text-inside-a-textinput-component/290928/1 "2009-06-22T12:25:36Z")

</div>

Hi!

I’d like to highlight / select text inside a textInput when the user sets the focus on it.  
My code (that doesn’t work):

```auto

txtInput.text="abcd"; // TextInput text

var txtInputListener:Object = new Object(); // create event listener
txtInput.addEventListener("focusIn", txtInputListener); // set listener

txtInputListener.focusIn=function(){ // focusIn event
txtInput.setSelection(0,txtInput.text.length); // Highlight the inner text
}

```

Thanks!
