# Problem with Selection.setFocus

**URL:** <https://forum.kirupa.com/t/problem-with-selection-setfocus/180791>\
**Category:** Uncategorized\
**Created:** [March 3, 2006, 2:05pm UTC](https://forum.kirupa.com/t/problem-with-selection-setfocus/180791 "2006-03-03T14:05:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wmostrey](https://avatars.discourse-cdn.com/v4/letter/w/f1d935/32.png) [@wmostrey](https://forum.kirupa.com/u/wmostrey)\
**Post date:** [March 3, 2006, 2:05pm UTC](https://forum.kirupa.com/t/problem-with-selection-setfocus/180791/1 "2006-03-03T14:05:23Z")

</div>

Hey all,

I’m working on a chat application which works with smilies. The smilies themselves work great, and I’m now at the point of adding a field with the 20 most popular smilies. When a user clicks them, the code (":-)" or “:p” for instance) gets added to the textfield. The problem is that after adding this code, I can’t seem to get the focus back on the input field, resulting in the user having to click it again.

Currently I have the following:

```auto
on(release) {
	_root.Application.msg.text += " :-)";
	Selection.setFocus("_root.Application.msg");
	Selection.setSelection(_root.Application.msg.length, _root.Application.msg.length);
	Selection.setFocus("_root.Application.msg");
}

```

I use the setSelection to get the cursor on the final position of the input field. The second setFocus doesn’t seem to put the focus back though…

Any help would be highly appreciated.
