# \[FAQ\] How to Debug Window Focus in .NET Apps

**URL:** <https://community.interop.io/t/faq-how-to-debug-window-focus-in-net-apps/523>\
**Category:** io.Connect Desktop\
**Created:** [March 12, 2026, 12:50pm UTC](https://community.interop.io/t/faq-how-to-debug-window-focus-in-net-apps/523 "2026-03-12T12:50:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![toni.petrov](https://yyz2.discourse-cdn.com/flex028/user_avatar/community.interop.io/toni.petrov/32/17_2.png) [@toni.petrov](https://community.interop.io/u/toni.petrov)\
**Post date:** [March 12, 2026, 12:50pm UTC](https://community.interop.io/t/faq-how-to-debug-window-focus-in-net-apps/523/1 "2026-03-12T12:50:32Z")

</div>

## Question

We have a multi-window .NET application running inside io.Connect Desktop. We want to know which view the user is currently focused on: for example, to route a toolbar action to the correct window, for keyboard shortcuts that behave differently depending on the active view, or to drive context-sensitive logic that depends on knowing where the user’s attention is.

## Answer

You can confirm that the io.Connect platform is actually emitting focus events with the help of DevTools. Open a DevTools console from any web app running inside io.Connect and run:

```auto
glue.windows.onWindowGotFocus((w) => console.info("got: " + w.id));
glue.windows.onWindowLostFocus((w) => console.info("lost: " + w.id));

```

Keep the console visible, then click between your .NET views. You should see entries logged as focus changes and this tells you whether the platform is aware of the focus transitions.

**Then make sure that in your code you handle the _type_ of the focus event:**

```csharp
glue_.GlueWindows.SubscribeEvents<WindowFocusChangedEvent>(((@event, descriptor) => {
   if (@event.Data) { /*got focus*/ } else { /*lost focus*/ }
}));

```

The event fires for **both** focus gained and focus lost. Without checking `@event.Data`, you may process a “lost focus” event as if it were a “got focus” event, leading to stale or disposed view references.

##
