diff options
Diffstat (limited to 'Common/NativeApp/src/UWP/App.cpp')
| -rw-r--r-- | Common/NativeApp/src/UWP/App.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Common/NativeApp/src/UWP/App.cpp b/Common/NativeApp/src/UWP/App.cpp index 6767b49..e0af485 100644 --- a/Common/NativeApp/src/UWP/App.cpp +++ b/Common/NativeApp/src/UWP/App.cpp @@ -103,6 +103,12 @@ void App::SetWindow(CoreWindow^ window) window->Closed += ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &App::OnWindowClosed); + window->KeyDown += + ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &App::OnKeyDown); + + window->KeyUp += + ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &App::OnKeyUp); + DisplayInformation^ currentDisplayInformation = DisplayInformation::GetForCurrentView(); currentDisplayInformation->DpiChanged += @@ -243,6 +249,47 @@ void App::OnDisplayContentsInvalidated(DisplayInformation^ sender, Object^ args) GetDeviceResources()->ValidateDevice(); } +void App::OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args) +{ + auto Key = args->VirtualKey; + switch(Key) + { + case VirtualKey::Escape: + CoreApplication::Exit(); + break; + + case VirtualKey::Enter: + if(m_bShiftPressed) + { + auto applicationView = Windows::UI::ViewManagement::ApplicationView::GetForCurrentView(); + if (applicationView->IsFullScreenMode) + { + applicationView->ExitFullScreenMode(); + } + else + { + applicationView->TryEnterFullScreenMode(); + } + } + break; + + case VirtualKey::Shift: + m_bShiftPressed = true; + break; + } +} + +void App::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args) +{ + auto Key = args->VirtualKey; + switch (Key) + { + case VirtualKey::Shift: + m_bShiftPressed = false; + break; + } +} + std::shared_ptr<DX::DeviceResources> App::GetDeviceResources() { if (m_deviceResources != nullptr && m_deviceResources->IsDeviceRemoved()) |
