# ClearFocus .... dangerous command?

**URL:** <https://forum.xojo.com/t/clearfocus-dangerous-command/24267>\
**Category:** General\
**Created:** [May 15, 2015, 3:39pm UTC](https://forum.xojo.com/t/clearfocus-dangerous-command/24267 "2015-05-15T15:39:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_Blazek](https://forum.xojo.com/letter_avatar_proxy/v4/letter/r/c68b51/32.png) [@Robert\_Blazek](https://forum.xojo.com/u/Robert_Blazek)\
**Post date:** [May 15, 2015, 3:39pm UTC](https://forum.xojo.com/t/clearfocus-dangerous-command/24267/1 "2015-05-15T15:39:41Z")

</div>

Try to position a textfield within a window and put a ClearFocus-Command into the GotFocus-Event.

Now when you run the program a massegebox explains, that the Debugtest.exe doesn’t work any more and you have to terminate the program.

If there are other textfields with other events in the window, this might not occur, but it can when you try to click on such a textfield and afterwards it will happen.

Bug-report is already done.

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [May 15, 2015, 5:50pm UTC](https://forum.xojo.com/t/clearfocus-dangerous-command/24267/2 "2015-05-15T17:50:37Z")

</div>

[quote=187385:@Robert Blazek]Try to position a textfield within a window and put a ClearFocus-Command into the GotFocus-Event.

Now when you run the program a massegebox explains, that the Debugtest.exe doesn’t work any more and you have to terminate the program.

If there are other textfields with other events in the window, this might not occur, but it can when you try to click on such a textfield and afterwards it will happen.

Bug-report is already done.[/quote]

Just set Tab Stop off and the Windows crash will be gone. Probably due to some conflict between the event and the ClearFocus command.

---

<div class="post-metadata">

**Author:** ![Robert\_Blazek](https://forum.xojo.com/letter_avatar_proxy/v4/letter/r/c68b51/32.png) [@Robert\_Blazek](https://forum.xojo.com/u/Robert_Blazek)\
**Post date:** [May 16, 2015, 6:00am UTC](https://forum.xojo.com/t/clearfocus-dangerous-command/24267/3 "2015-05-16T06:00:34Z")

</div>

Thanks Michael,

It also helps, if you make it conditional:

`If x=true then
Clearfocus
end if`  
And x=true can be always true,

But this is nowhere documented. So I call it a bug.

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [May 16, 2015, 8:20am UTC](https://forum.xojo.com/t/clearfocus-dangerous-command/24267/4 "2015-05-16T08:20:02Z")

</div>

Robert,  
the part `=true` is not mandatory: you can use `if x then`

Note: I had to edit this post four times adding text to work-around a bug in the software. =true set as code at the line start is buggy.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 5:45pm UTC](https://forum.xojo.com/t/clearfocus-dangerous-command/24267/5 "2020-10-29T17:45:22Z")

</div>


