/// <summary> /// Creates a new TextAreaDefaultInputHandler instance. /// </summary> public TextAreaDefaultInputHandler(TextArea textArea) : base(textArea) { NestedInputHandlers.Add(CaretNavigation = CaretNavigationCommandHandler.Create(textArea)); NestedInputHandlers.Add(Editing = EditingCommandHandler.Create(textArea)); NestedInputHandlers.Add(MouseSelection = new SelectionMouseHandler(textArea)); AddBinding(ApplicationCommands.Undo, ExecuteUndo, CanExecuteUndo); AddBinding(ApplicationCommands.Redo, ExecuteRedo, CanExecuteRedo); }
/// <summary> /// reset flag as an asynchronous operation. /// </summary> protected async Task ResetFlagAsync() { await Task.Delay(100); handleAllEvents = false; if (mouseHandler != null) { mouseHandler.Detach(); NestedInputHandlers.Add(mouseHandler); } }
/// <summary> /// Handles the PointerPressed event of the TextArea control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="PointerPressedEventArgs" /> instance containing the event data.</param> private void TextArea_PointerPressed(object sender, PointerPressedEventArgs e) { // Avalonia edit is killing RMB var rmb = IsRightMouseButton(e.GetCurrentPoint(null)); if (rmb && editor.ContextMenu != null) { // Aside from forking the whole project over and fixing the mess, we can hack our way around. It just ain't worth it. if (mouseHandler == null) { mouseHandler = NestedInputHandlers.FirstOrDefault(p => p.GetType().Name.Contains("SelectionMouseHandler")); } handleAllEvents = true; NestedInputHandlers.Remove(mouseHandler); editor.ContextMenu.Open(editor); } }