# Txtfield Selection pb!

**URL:** <https://forum.kirupa.com/t/txtfield-selection-pb/117564>\
**Category:** Uncategorized\
**Created:** [July 28, 2004, 1:41pm UTC](https://forum.kirupa.com/t/txtfield-selection-pb/117564 "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/117564/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:** ![El\_Phantom](https://avatars.discourse-cdn.com/v4/letter/e/d6d6ee/32.png) [@El\_Phantom](https://forum.kirupa.com/u/El_Phantom)\
**Post date:** [July 29, 2004, 1:01am UTC](https://forum.kirupa.com/t/txtfield-selection-pb/117564/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:** ![kode](https://avatars.discourse-cdn.com/v4/letter/k/97f17d/32.png) [@kode](https://forum.kirupa.com/u/kode)\
**Post date:** [July 29, 2004, 1:04am UTC](https://forum.kirupa.com/t/txtfield-selection-pb/117564/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:** ![Uli](https://avatars.discourse-cdn.com/v4/letter/u/ccd318/32.png) [@Uli](https://forum.kirupa.com/u/Uli)\
**Post date:** [July 29, 2004, 1:08am UTC](https://forum.kirupa.com/t/txtfield-selection-pb/117564/4 "2004-07-29T01:08:22Z")

</div>

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