diff --git a/Directory.Build.props b/Directory.Build.props index 6f2ded36..c21a30ab 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ latest true - 11.0.0-preview8 + 11.0.0-rc1.1 1.0.55 beta diff --git a/src/AvaloniaEdit.Demo/MainWindow.xaml.cs b/src/AvaloniaEdit.Demo/MainWindow.xaml.cs index 01ce49bc..47cb6cc8 100644 --- a/src/AvaloniaEdit.Demo/MainWindow.xaml.cs +++ b/src/AvaloniaEdit.Demo/MainWindow.xaml.cs @@ -347,7 +347,7 @@ public MyCompletionData(string text) Text = text; } - public IBitmap Image => null; + public Bitmap Image => null; public string Text { get; } diff --git a/src/AvaloniaEdit/CodeCompletion/CompletionWindow.cs b/src/AvaloniaEdit/CodeCompletion/CompletionWindow.cs index 139aebdb..e2d71c8b 100644 --- a/src/AvaloniaEdit/CodeCompletion/CompletionWindow.cs +++ b/src/AvaloniaEdit/CodeCompletion/CompletionWindow.cs @@ -174,7 +174,7 @@ protected override void OnKeyDown(KeyEventArgs e) private void TextArea_PreviewTextInput(object sender, TextInputEventArgs e) { e.Handled = RaiseEventPair(this, null, TextInputEvent, - new TextInputEventArgs { Device = e.Device, Text = e.Text }); + new TextInputEventArgs { Text = e.Text }); } private void TextArea_MouseWheel(object sender, PointerWheelEventArgs e) diff --git a/src/AvaloniaEdit/CodeCompletion/CompletionWindowBase.cs b/src/AvaloniaEdit/CodeCompletion/CompletionWindowBase.cs index ea7725f6..7f6ff600 100644 --- a/src/AvaloniaEdit/CodeCompletion/CompletionWindowBase.cs +++ b/src/AvaloniaEdit/CodeCompletion/CompletionWindowBase.cs @@ -218,7 +218,7 @@ public override void OnPreviewKeyDown(KeyEventArgs e) if (e.Key == Key.DeadCharProcessed) return; e.Handled = RaiseEventPair(Window, null, KeyDownEvent, - new KeyEventArgs { Device = e.Device, Key = e.Key }); + new KeyEventArgs { Key = e.Key }); } public override void OnPreviewKeyUp(KeyEventArgs e) @@ -226,7 +226,7 @@ public override void OnPreviewKeyUp(KeyEventArgs e) if (e.Key == Key.DeadCharProcessed) return; e.Handled = RaiseEventPair(Window, null, KeyUpEvent, - new KeyEventArgs { Device = e.Device, Key = e.Key }); + new KeyEventArgs { Key = e.Key }); } } #endregion diff --git a/src/AvaloniaEdit/CodeCompletion/ICompletionData.cs b/src/AvaloniaEdit/CodeCompletion/ICompletionData.cs index 3fc3e15f..a0147b43 100644 --- a/src/AvaloniaEdit/CodeCompletion/ICompletionData.cs +++ b/src/AvaloniaEdit/CodeCompletion/ICompletionData.cs @@ -35,7 +35,7 @@ public interface ICompletionData /// /// Gets the image. /// - IBitmap Image { get; } + Bitmap Image { get; } /// /// Gets the text. This property is used to filter the list of visible elements. diff --git a/src/AvaloniaEdit/Editing/CaretNavigationCommandHandler.cs b/src/AvaloniaEdit/Editing/CaretNavigationCommandHandler.cs index 2ea16d72..dc7c3710 100644 --- a/src/AvaloniaEdit/Editing/CaretNavigationCommandHandler.cs +++ b/src/AvaloniaEdit/Editing/CaretNavigationCommandHandler.cs @@ -82,7 +82,7 @@ private static void AddBinding(RoutedCommand command, KeyGesture gesture, EventH static CaretNavigationCommandHandler() { - var keymap = AvaloniaLocator.Current.GetService(); + var keymap = Application.Current.PlatformSettings.HotkeyConfiguration; AddBinding(EditingCommands.MoveLeftByCharacter, KeyModifiers.None, Key.Left, OnMoveCaret(CaretMovementType.CharLeft)); AddBinding(EditingCommands.SelectLeftByCharacter, keymap.SelectionModifiers, Key.Left, OnMoveCaretExtendSelection(CaretMovementType.CharLeft)); diff --git a/src/AvaloniaEdit/RoutedCommand.cs b/src/AvaloniaEdit/RoutedCommand.cs index a570115c..daa24f88 100644 --- a/src/AvaloniaEdit/RoutedCommand.cs +++ b/src/AvaloniaEdit/RoutedCommand.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Windows.Input; -using Avalonia; using Avalonia.Input; using Avalonia.Interactivity; @@ -10,6 +9,8 @@ namespace AvaloniaEdit { public class RoutedCommand : ICommand { + private static IInputElement _inputElement; + public string Name { get; } public KeyGesture Gesture { get; } @@ -23,6 +24,7 @@ static RoutedCommand() { CanExecuteEvent.AddClassHandler(CanExecuteEventHandler); ExecutedEvent.AddClassHandler(ExecutedEventHandler); + InputElement.GotFocusEvent.AddClassHandler(GotFocusEventHandler); } private static void CanExecuteEventHandler(Interactive control, CanExecuteRoutedEventArgs args) @@ -46,6 +48,11 @@ private static void ExecutedEventHandler(Interactive control, ExecutedRoutedEven } } + private static void GotFocusEventHandler(Interactive control, GotFocusEventArgs args) + { + _inputElement = control as IInputElement; + } + public static RoutedEvent CanExecuteEvent { get; } = RoutedEvent.Register(nameof(CanExecuteEvent), RoutingStrategies.Bubble, typeof(RoutedCommand)); public bool CanExecute(object parameter, IInputElement target) @@ -60,7 +67,7 @@ public bool CanExecute(object parameter, IInputElement target) bool ICommand.CanExecute(object parameter) { - return CanExecute(parameter, Application.Current.FocusManager.Current); + return CanExecute(parameter, _inputElement); } public static RoutedEvent ExecutedEvent { get; } = RoutedEvent.Register(nameof(ExecutedEvent), RoutingStrategies.Bubble, typeof(RoutedCommand)); @@ -75,7 +82,7 @@ public void Execute(object parameter, IInputElement target) void ICommand.Execute(object parameter) { - Execute(parameter, Application.Current.FocusManager.Current); + Execute(parameter, _inputElement); } // TODO diff --git a/test/AvaloniaEdit.Tests/AvaloniaEdit.Tests.csproj b/test/AvaloniaEdit.Tests/AvaloniaEdit.Tests.csproj index b7b4234e..c1902d7c 100644 --- a/test/AvaloniaEdit.Tests/AvaloniaEdit.Tests.csproj +++ b/test/AvaloniaEdit.Tests/AvaloniaEdit.Tests.csproj @@ -5,10 +5,10 @@ - - - - + + + +