Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XNA - how to determine which window has focus?

Tags:

xna

I'm thinking about writing an XNA game for Windows. It will have the main game window and another WPF form that has some chat controls or debugging information. When I'm typing something into this auxiliary form, obviously I don't want the main XNA window to see what I'm typing.

What is the best way to do this? I thought that if I can determine if the auxiliary window has the focus, I could ignore any keystrokes in my game loop. But making that determination isn't obvious in XNA. How is this done?

like image 931
Mossen Avatar asked Dec 27 '22 19:12

Mossen


1 Answers

Check Game.IsActive (MSDN) before responding to any input changes.

like image 123
Andrew Russell Avatar answered Dec 30 '22 12:12

Andrew Russell