# Selection.setfocus

**URL:** <https://forum.kirupa.com/t/selection-setfocus/15574>\
**Category:** Uncategorized\
**Created:** [March 15, 2003, 10:31pm UTC](https://forum.kirupa.com/t/selection-setfocus/15574 "2003-03-15T22:31:05Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Seticus](https://avatars.discourse-cdn.com/v4/letter/s/46a35a/32.png) [@Seticus](https://forum.kirupa.com/u/Seticus)\
**Post date:** [March 15, 2003, 10:31pm UTC](https://forum.kirupa.com/t/selection-setfocus/15574/1 "2003-03-15T22:31:05Z")

</div>

Well, i know, it sounds easy, but the only thing I want to do is make a textfield that’s always focused. When I click next to the textfield on a picture or on the root the focus changes and that’s not what I need, the textfield has to stay focused. Could anyone give me that script please?

Thank you so much

---

<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:** [March 16, 2003, 9:32am UTC](https://forum.kirupa.com/t/selection-setfocus/15574/2 "2003-03-16T09:32:42Z")

</div>

Are you saying that the text field should be focused even when something else, for example picture, gets clicked???

---

<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:** [March 16, 2003, 10:02am UTC](https://forum.kirupa.com/t/selection-setfocus/15574/3 "2003-03-16T10:02:08Z")

</div>

that’s right, I think it’s possible. don’t you? :nerd:

---

<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:** [March 16, 2003, 10:14am UTC](https://forum.kirupa.com/t/selection-setfocus/15574/4 "2003-03-16T10:14:26Z")

</div>

Well… you can have a listener or something running all the time and have that refocus your text field, I guess… But I don’t understand why you want to do it though…

---

<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:** [March 16, 2003, 10:26am UTC](https://forum.kirupa.com/t/selection-setfocus/15574/5 "2003-03-16T10:26:25Z")

</div>

I’ll show you [Go here](http://www.collegeveurne.be/in%20opmaak/site.html) When you lose the focus, it’s hard to get it back because there’s a mask running over it. I tried using a listener, but i don’t quite understand how to do that… ☹

---

<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:** [March 16, 2003, 10:41am UTC](https://forum.kirupa.com/t/selection-setfocus/15574/6 "2003-03-16T10:41:00Z")

</div>

Well… If that is the case… =)

Something like this might work… (Untested…)

```auto
Selection.setFocus("_level0.focusMe");

focusListener = new Object();
focusListener.onMouseDown = function ()
{
	if (Selection.getFocus() != "_level0.focusMe")
	{
		Selection.setFocus("_level0.focusMe");
	}
}
Mouse.addListener(focusListener);

```

Do some more searching on the forum regarding the listener and setFocus…

BTW, that alpha tween in that site almost killed my PII 300… :-\

---

<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:** [March 16, 2003, 10:49am UTC](https://forum.kirupa.com/t/selection-setfocus/15574/7 "2003-03-16T10:49:14Z")

</div>

Not a perfect one, but here is a simple sample that might help you understand how this thing can be done… Good luck… 😉

---

<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:** [March 16, 2003, 11:21am UTC](https://forum.kirupa.com/t/selection-setfocus/15574/8 "2003-03-16T11:21:16Z")

</div>

thank you so much, it’s great, but… when you kill the focus it selects the text, is their a way to unselect it again?

and what do you mean by almost killed my PII300, is it to slow? mm, i’ll work on it, but it’s not CPU intensive

---

<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:** [March 16, 2003, 11:31am UTC](https://forum.kirupa.com/t/selection-setfocus/15574/9 "2003-03-16T11:31:14Z")

</div>

Use Selection.setSelection() to select the last one in the text field so that the selection won’t be made…

As for alpha tween… Yes… When the alpha tween happened, my machine almost froze until the alpha tween was happening… Alpha tween for the big portion of the screen is supposed to be CPU intensive though…
