Sign in to follow this  
Gravy

Game still picking up mouse clicks even tho not active?!?

Recommended Posts

Hello, everybody, how are you?

This is just kinda annoying more thing else. Okay, I'm programming my game trying to solve bugs and errors. I have it set so when I click on certain objects it writes stuff to the debug window. So I'll click a few things then make visual studio the active window and I'll start scrolling thru the output and clicking on the coding part of the window to scroll thru my code trying to figure out whats going on, and I notice that when I click anywhere where the game window is in the background and I happen to click on a object it writes to the output window. Even if I'm in another program like my messenger and I click on something it still shows up in the output window??? Is it suppose to do that, because its in debug mode and can't check if its the active window? Or do I have to tell it not to do that?

Just wondering really?

Share this post


Link to post
Share on other sites
Just check if your app is the active window before processing the KB/mouse input routines.

Share this post


Link to post
Share on other sites
I'm using the MouseState that comes with XNA 4.0. It doesn't pick up keyboard input just the mouse.

So I guess I have to tell it not to do that? I assumed it would be built in to the windows already. I guess I'll look into that.

Share this post


Link to post
Share on other sites
In XNA it is Game.IsActive. So the in the Game.Update() function you will do something like this:


protected override void Update(GameTime gameTime)
{
// update kb and mouse only if the game window is active
// otherwise keypresses in other applications will register
if (this.IsActive)
{
UpdateMouse();
UpdateKB();
}

// etc...
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this