diff --git a/projects/VS2017.UWP/raylib.App.UWP/App.cpp b/projects/VS2017.UWP/raylib.App.UWP/App.cpp index 517672d3c..a1faa70d2 100644 --- a/projects/VS2017.UWP/raylib.App.UWP/App.cpp +++ b/projects/VS2017.UWP/raylib.App.UWP/App.cpp @@ -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(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() { diff --git a/projects/VS2017.UWP/raylib.App.UWP/App.h b/projects/VS2017.UWP/raylib.App.UWP/App.h index 892d85922..a3b7577f4 100644 --- a/projects/VS2017.UWP/raylib.App.UWP/App.h +++ b/projects/VS2017.UWP/raylib.App.UWP/App.h @@ -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