Fix game closing on Xbox when B is pressed.
This commit is contained in:
parent
3767a324a7
commit
95c03b2fee
|
|
@ -83,6 +83,10 @@ void App::SetWindow(Windows::UI::Core::CoreWindow^ window)
|
|||
|
||||
// The CoreWindow has been created, we can pass this to raylib for EGL context creation when it's time
|
||||
UWPSetCoreWindowPtr((void*)window);
|
||||
|
||||
// Register backrequested event to stop window from being closed (Most noticable on XBox when B is pressed)
|
||||
auto navigation = SystemNavigationManager::GetForCurrentView();
|
||||
navigation->BackRequested += ref new Windows::Foundation::EventHandler<Windows::UI::Core::BackRequestedEventArgs^>(this, &raylibUWP::App::OnBackRequested);
|
||||
}
|
||||
|
||||
void App::Load(Platform::String ^entryPoint) {} // Ignored for this example
|
||||
|
|
@ -454,6 +458,12 @@ void App::OnCharacterReceived(Windows::UI::Core::CoreWindow^ sender, Windows::UI
|
|||
UWPKeyCharEvent(args->KeyCode);
|
||||
}
|
||||
|
||||
void App::OnBackRequested(Platform::Object^ sender, Windows::UI::Core::BackRequestedEventArgs^ args)
|
||||
{
|
||||
// This simply stops the program from closing.
|
||||
args->Handled = true;
|
||||
}
|
||||
|
||||
// AppSource implementation
|
||||
Windows::ApplicationModel::Core::IFrameworkView ^AppSource::CreateView()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ namespace raylibUWP
|
|||
void OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
|
||||
void OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
|
||||
void OnCharacterReceived(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CharacterReceivedEventArgs^ args);
|
||||
void OnBackRequested(Platform::Object^ sender, Windows::UI::Core::BackRequestedEventArgs^ args);
|
||||
};
|
||||
|
||||
ref class AppSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user