# How to determine which control has focus?

**URL:** <https://forum.xojo.com/t/how-to-determine-which-control-has-focus/9524>\
**Category:** Web\
**Created:** [July 14, 2013, 2:32pm UTC](https://forum.xojo.com/t/how-to-determine-which-control-has-focus/9524 "2013-07-14T14:32:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeremy\_Cowgar](https://forum.xojo.com/user_avatar/forum.xojo.com/jeremy_cowgar/32/4590_2.png) [@Jeremy\_Cowgar](https://forum.xojo.com/u/Jeremy_Cowgar)\
**Post date:** [July 14, 2013, 2:32pm UTC](https://forum.xojo.com/t/how-to-determine-which-control-has-focus/9524/1 "2013-07-14T14:32:55Z")

</div>

I am trying to work around bug \<[https://xojo.com/issue/17130](https://xojo.com/issue/17130)\> (WE: Listbox KeyPressed event does not fire) by adding a page KeyPressed event handler. It’s easy enough to handle up/down and other various key combos in this case, but with other widgets on the screen, the page KeyPressed responds when any widget is active, for example a textbox. If, then, you have your cursor in the TextBox and press the Up arrow key, your cursor does go up, but then the page key event is fired and whatever you have your Up key doing there is performed as well.

I was thinking of checking to see what widget is currently focused, but am failing in that area.

I attempted to implement GotFocus/LostFocus event handlers for all widgets and set a page variable `IgnorePageKeyEvent` but some widgets on my page (radio button groups) don’t seem to get focus events, thus the variable is not set for all widgets.

Any thoughts?

---

<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, 4:44pm UTC](https://forum.xojo.com/t/how-to-determine-which-control-has-focus/9524/2 "2020-10-29T16:44:59Z")

</div>


