# Txtfield Selection pb!

**URL:** <https://forum.kirupa.com/t/txtfield-selection-pb/59099>\
**Category:** flash\
**Created:** [July 28, 2004, 1:41pm UTC](https://forum.kirupa.com/t/txtfield-selection-pb/59099 "2004-07-28T13:41:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Uli](https://avatars.discourse-cdn.com/v4/letter/u/ccd318/32.png) [@Uli](https://forum.kirupa.com/u/Uli)\
**Post date:** [July 28, 2004, 1:41pm UTC](https://forum.kirupa.com/t/txtfield-selection-pb/59099/1 "2004-07-28T13:41:56Z")

</div>

Hello,

What i’m trying to do is trace the selection of a txtfield using a button… I started like that :

```php

this.btbold.onPress = function() {
	mylt = new Object();
	Selection.addListener(mylt);
	Selection.setFocus(_root.mytf);

```

My pb is, i have to set focus 1st on the txtfield, as the flash help says, but my selection becomes the whole txtfield… I only want ot be able to trace my current selection… How should i do?? TiA :thumb:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 29, 2004, 1:01am UTC](https://forum.kirupa.com/t/txtfield-selection-pb/59099/2 "2004-07-29T01:01:21Z")

</div>

probably use  
Selection.getBeginIndex();  
Selection.getEndIndex();  
and then use a substring function or something to get the text.

–EP

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 29, 2004, 1:04am UTC](https://forum.kirupa.com/t/txtfield-selection-pb/59099/3 "2004-07-29T01:04:47Z")

</div>

The real problem is that once that the button is pressed you’ll lose focus on the text field; therefore, the selection will be lost. 😛

I’d probably try something like this, see attachment. 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 29, 2004, 1:08am UTC](https://forum.kirupa.com/t/txtfield-selection-pb/59099/4 "2004-07-29T01:08:22Z")

</div>

Yep exactly what i needed, you rock !! Thanks a bunch !! :p:
