Esc to dismiss too

This commit is contained in:
Mike Griese 2021-10-28 07:03:11 -05:00
parent 7fb490629b
commit b9979ffaf8
3 changed files with 35 additions and 2 deletions

View file

@ -6,6 +6,7 @@
#include "pch.h"
#include "AdminWarningPlaceholder.h"
#include "AdminWarningPlaceholder.g.cpp"
#include <LibraryResources.h>
using namespace winrt::Windows::UI::Xaml;
using namespace winrt::Windows::UI::Xaml::Automation::Peers;
@ -59,4 +60,16 @@ namespace winrt::TerminalApp::implementation
{
return RS_(L"AdminWarningPlaceholderName");
}
void AdminWarningPlaceholder::_keyUpHandler(IInspectable const& /*sender*/,
Windows::UI::Xaml::Input::KeyRoutedEventArgs const& e)
{
// If the user presses escape, close the dialog (without confirming)
const auto key = e.OriginalKey();
if (key == winrt::Windows::System::VirtualKey::Escape)
{
_CancelButtonClickedHandlers(*this, e);
e.Handled(true);
}
}
}

View file

@ -1,5 +1,22 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/*++
Copyright (c) Microsoft Corporation
Licensed under the MIT license.
Module Name:
- AdminWarningPlaceholder
Abstract:
- The AdminaWarningPlaceholder is a control used to fill space in a pane and
present a warning to the user. It holds on to a real control that it should be
replaced with. It looks just like a ContentDialog, except it exists per-pane,
whereas a ContentDialog can only be added to take up the whole window.
- The caller should make sure to bind our PrimaryButtonClicked and
CancelButtonClicked events, to be informed as to which was pressed.
Author(s):
- Mike Griese - September 2021
--*/
#pragma once
@ -28,5 +45,7 @@ namespace winrt::TerminalApp::implementation
winrt::Windows::UI::Xaml::RoutedEventArgs const& e);
void _cancelButtonClick(winrt::Windows::Foundation::IInspectable const& sender,
winrt::Windows::UI::Xaml::RoutedEventArgs const& e);
void _keyUpHandler(Windows::Foundation::IInspectable const& sender,
Windows::UI::Xaml::Input::KeyRoutedEventArgs const& e);
};
}

View file

@ -12,6 +12,7 @@
AutomationProperties.AccessibilityView="Content"
AutomationProperties.IsDialog="True"
AutomationProperties.Name="{x:Bind ControlName, Mode=OneWay}"
PreviewKeyUp="_keyUpHandler"
mc:Ignorable="d">
<!--