8947909121
## Summary of the Pull Request Replaces the key chord editor in the actions page with a listener instead of a plain text box. ## References #6900 - Settings UI Epic ## Detailed Description of the Pull Request / Additional comments - `Actions` page: - Replace `Keys` with `CurrentKeys` for consistency with `Action`/`CurrentAction` - `ProposedKeys` is now a `Control::KeyChord` - removes key chord validation (now we don't need it) - removes accept/cancel shortcuts (nowhere we could use it now) - `KeyChordListener`: - `Keys`: dependency property that hooks us up to a system to the committed setting value - this is the key binding view model, which propagates the change to the settings model clone on "accept changes" - We bind to `PreviewKeyDown` to intercept the key event _before_ some special key bindings are handled (i.e. "select all" in the text box) - `CoreWindow` is used to get the modifier keys because (1) it's easier than updating on each key press and (2) that approach resulted in a strange bug where the <kbd>Alt</kbd> key-up event was not detected - `LosingFocus` means that we have completed our operation and want to commit our changes to the key binding view model - `KeyDown` does most of the magic of updating `Keys`. We filter out any key chords that could be problematic (i.e. <kbd>Shift</kbd>+<kbd>Tab</kbd> and <kbd>Tab</kbd> for keyboard navigation) ## Validation Steps Performed - Tested a few key chords: - ✅single key: <kbd>X</kbd> - ✅key with modifier(s): <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>X</kbd> - ❌plain modifier: <kbd>Ctrl</kbd> - ✅key that is used by text box: <kbd>Ctrl+A</kbd> - ✅key that is used by Windows Terminal: <kbd>Alt</kbd>+<kbd>F4</kbd> - ❌key that is taken by Windows OS: <kbd>Windows</kbd>+<kbd>X</kbd> - ✅key that is not taken by Windows OS: <kbd>Windows</kbd>+<kbd>Shift</kbd>+<kbd>X</kbd> - Known issue: - global key taken by Windows Terminal: (i.e. quake mode keybinding) - Behavior: global key binding executed - Expected: key chord recorded ## Demo ![Key Chord Listener Demo](https://user-images.githubusercontent.com/11050425/125538094-08ea4eaa-21eb-4488-a74c-6ce65324cdf1.gif)
59 lines
1.9 KiB
C
59 lines
1.9 KiB
C
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
//
|
|
// pch.h
|
|
// Header for platform projection include files
|
|
//
|
|
|
|
#pragma once
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
// Manually include til after we include Windows.Foundation to give it winrt superpowers
|
|
#define BLOCK_TIL
|
|
#include <LibraryIncludes.h>
|
|
// This is inexplicable, but for whatever reason, cppwinrt conflicts with the
|
|
// SDK definition of this function, so the only fix is to undef it.
|
|
// from WinBase.h
|
|
// Windows::UI::Xaml::Media::Animation::IStoryboard::GetCurrentTime
|
|
#ifdef GetCurrentTime
|
|
#undef GetCurrentTime
|
|
#endif
|
|
|
|
#include <winrt/Windows.ApplicationModel.h>
|
|
#include <winrt/Windows.Foundation.h>
|
|
#include <winrt/Windows.Foundation.Collections.h>
|
|
#include <winrt/Windows.Globalization.h>
|
|
#include <winrt/Windows.System.h>
|
|
#include <winrt/Windows.UI.h>
|
|
#include <winrt/Windows.UI.Core.h>
|
|
#include <winrt/Windows.UI.Input.h>
|
|
#include <winrt/Windows.UI.Popups.h>
|
|
#include <winrt/Windows.UI.Text.h>
|
|
#include <winrt/Windows.UI.Xaml.h>
|
|
#include <winrt/Windows.UI.Xaml.Automation.h>
|
|
#include <winrt/Windows.UI.Xaml.Automation.Peers.h>
|
|
#include <winrt/Windows.UI.Xaml.Controls.h>
|
|
#include <winrt/Windows.UI.Xaml.Controls.Primitives.h>
|
|
#include <winrt/Windows.UI.Xaml.Data.h>
|
|
#include <winrt/Windows.UI.Xaml.Input.h>
|
|
#include <winrt/Windows.UI.Xaml.Interop.h>
|
|
#include <winrt/Windows.UI.Xaml.Markup.h>
|
|
#include <winrt/Windows.UI.Xaml.Media.h>
|
|
#include <winrt/Windows.UI.Xaml.Navigation.h>
|
|
|
|
#include <winrt/Microsoft.UI.Xaml.Controls.h>
|
|
#include <winrt/Microsoft.UI.Xaml.XamlTypeInfo.h>
|
|
|
|
#include <winrt/Microsoft.Terminal.Core.h>
|
|
#include <winrt/Microsoft.Terminal.Control.h>
|
|
#include <winrt/Microsoft.Terminal.Settings.Model.h>
|
|
|
|
#include <shlobj.h>
|
|
#include <shobjidl_core.h>
|
|
#include <dwrite.h>
|
|
#include <dwrite_1.h>
|
|
|
|
// Manually include til after we include Windows.Foundation to give it winrt superpowers
|
|
#include "til.h"
|