From 96873d1f62934967cc15e4c601704978ab1ed0aa Mon Sep 17 00:00:00 2001 From: Aaron Bockover Date: Wed, 2 Oct 2019 10:13:21 -0400 Subject: Sync with vs-editor-core@4624fd16 --- src/Editor/Text/Def/TextUICocoa/Input/KeyEvent.cs | 34 ++++++++++++++++++++++ .../Text/Def/TextUICocoa/Input/KeyProcessor.cs | 33 ++++++++++++++------- 2 files changed, 56 insertions(+), 11 deletions(-) create mode 100644 src/Editor/Text/Def/TextUICocoa/Input/KeyEvent.cs diff --git a/src/Editor/Text/Def/TextUICocoa/Input/KeyEvent.cs b/src/Editor/Text/Def/TextUICocoa/Input/KeyEvent.cs new file mode 100644 index 0000000..eab7599 --- /dev/null +++ b/src/Editor/Text/Def/TextUICocoa/Input/KeyEvent.cs @@ -0,0 +1,34 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// + +using System; +using AppKit; + +namespace Microsoft.VisualStudio.Text.Editor +{ + /// + /// A native key input event that allows for indicating that + /// the event has been handled. This event will wrap , + /// , and + /// events. + /// + public sealed class KeyEvent : InputEvent + { + internal KeyEvent(NSEvent @event) : base(@event) + { + switch (@event.Type) + { + case NSEventType.KeyUp: + case NSEventType.KeyDown: + case NSEventType.FlagsChanged: + break; + default: + throw new ArgumentException( + "event type must be KeyUp, KeyDown, or FlagsChanged", + nameof(@event)); + } + } + } +} \ No newline at end of file diff --git a/src/Editor/Text/Def/TextUICocoa/Input/KeyProcessor.cs b/src/Editor/Text/Def/TextUICocoa/Input/KeyProcessor.cs index 5824b13..c45269f 100644 --- a/src/Editor/Text/Def/TextUICocoa/Input/KeyProcessor.cs +++ b/src/Editor/Text/Def/TextUICocoa/Input/KeyProcessor.cs @@ -2,10 +2,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // + namespace Microsoft.VisualStudio.Text.Editor { - using AppKit; - /// /// Processes the keyboard input of the editor. /// @@ -14,28 +13,40 @@ namespace Microsoft.VisualStudio.Text.Editor /// public abstract class KeyProcessor { + /// + /// Determines whether this processor should be called for events that have + /// been handled by earlier objects. + /// + public virtual bool IsInterestedInHandledEvents => false; + /// /// Handles the KeyDown event. /// - /// - /// A describing the key event. + /// + /// Event arguments that describe the event. /// - public virtual void KeyDown(NSEvent theEvent) { } + public virtual void KeyDown(KeyEvent e) + { + } /// /// Handles the KeyUp event. /// - /// - /// A describing the key event. + /// + /// Event arguments that describe the event. /// - public virtual void KeyUp(NSEvent theEvent) { } + public virtual void KeyUp(KeyEvent e) + { + } /// /// Handles the FlagsChanged event. /// - /// - /// A describing the key event. + /// + /// Event arguments that describe the event. /// - public virtual void FlagsChanged(NSEvent theEvent) { } + public virtual void FlagsChanged(KeyEvent e) + { + } } } -- cgit v1.2.3