Click here to Skip to main content
15,867,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm using a framework in UWP that currently causes a problem for me. I can click my keyboard keys to move a character in a game I'm working on, but as soon as I click the mouse button, the UWP MainPage loses focus. ...or at least, keyboard input isn't doing anything anymore. Perhaps the root of the app takes over, but I'm not sure, and if so, I'm not sure how to remedy it.

Regardless of what has happened, I wonder if there is a way to easily set my canvas control as the active control, re-enabling keyboard input.

Does anyone recognise this problem? Apologies if the question doesn't make sense to you - it seems like a very strange problem and I don't fully understand it myself, only its consequences.

Thanks!

Petter

What I have tried:

I've tried this code:

C#
private void Page_PointerReleased(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
{
    this.Focus(FocusState.Programmatic);
}


but it didn't do anything, ie. it didn't eable keyboard input. However, it did fire when I released the mouse button. So, what I'm looking for is a way to reset my canvas as the "active" control, so that I can use keyboard input again.
Posted
Updated 10-Jul-16 22:28pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900