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:
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.