Merge pull request #446 from ablibrary-net/Mouse-ContextFlyout-Commands
Mouse ContextFlyout commands fix in AvaloniaEdit.Demo
This commit is contained in:
Коммит
f35f37a818
|
@ -51,6 +51,16 @@
|
|||
HorizontalScrollBarVisibility="Auto"
|
||||
VerticalScrollBarVisibility="Visible"
|
||||
FontWeight="Light"
|
||||
FontSize="14" />
|
||||
FontSize="14" >
|
||||
<AvalonEdit:TextEditor.ContextFlyout>
|
||||
<MenuFlyout>
|
||||
<MenuItem Header="Copy" InputGesture="ctrl+C" Command="{Binding CopyMouseCommmand}" CommandParameter="{Binding #Editor.TextArea}"></MenuItem>
|
||||
<MenuItem Header="Cut" InputGesture="ctrl+X" Command="{Binding CutMouseCommand}" CommandParameter="{Binding #Editor.TextArea}"></MenuItem>
|
||||
<MenuItem Header="Paste" InputGesture="ctrl+V" Command="{Binding PasteMouseCommmand}" CommandParameter="{Binding #Editor.TextArea}"></MenuItem>
|
||||
<MenuItem Header="-"/>
|
||||
<MenuItem Header="Select All" InputGesture="ctrl+A" Command="{Binding SelectAllMouseCommmand}" CommandParameter="{Binding #Editor.TextArea}"></MenuItem>
|
||||
</MenuFlyout>
|
||||
</AvalonEdit:TextEditor.ContextFlyout>
|
||||
</AvalonEdit:TextEditor>
|
||||
</DockPanel>
|
||||
</Window>
|
|
@ -51,15 +51,6 @@ namespace AvaloniaEdit.Demo
|
|||
_textEditor.HorizontalScrollBarVisibility = Avalonia.Controls.Primitives.ScrollBarVisibility.Visible;
|
||||
_textEditor.Background = Brushes.Transparent;
|
||||
_textEditor.ShowLineNumbers = true;
|
||||
_textEditor.ContextMenu = new ContextMenu
|
||||
{
|
||||
ItemsSource = new List<MenuItem>
|
||||
{
|
||||
new MenuItem { Header = "Copy", InputGesture = new KeyGesture(Key.C, KeyModifiers.Control) },
|
||||
new MenuItem { Header = "Paste", InputGesture = new KeyGesture(Key.V, KeyModifiers.Control) },
|
||||
new MenuItem { Header = "Cut", InputGesture = new KeyGesture(Key.X, KeyModifiers.Control) }
|
||||
}
|
||||
};
|
||||
_textEditor.TextArea.Background = this.Background;
|
||||
_textEditor.TextArea.TextEntered += textEditor_TextArea_TextEntered;
|
||||
_textEditor.TextArea.TextEntering += textEditor_TextArea_TextEntering;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.ObjectModel;
|
||||
using AvaloniaEdit.Editing;
|
||||
using ReactiveUI;
|
||||
using TextMateSharp.Grammars;
|
||||
|
||||
|
@ -18,4 +19,30 @@ public class MainWindowViewModel(TextMate.TextMate.Installation _textMateInstall
|
|||
_textMateInstallation.SetTheme(_registryOptions.LoadTheme(value.ThemeName));
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyMouseCommmand(TextArea textArea)
|
||||
{
|
||||
ApplicationCommands.Copy.Execute(null, textArea);
|
||||
}
|
||||
|
||||
public void CutMouseCommand(TextArea textArea)
|
||||
{
|
||||
ApplicationCommands.Cut.Execute(null, textArea);
|
||||
}
|
||||
|
||||
public void PasteMouseCommmand(TextArea textArea)
|
||||
{
|
||||
ApplicationCommands.Paste.Execute(null, textArea);
|
||||
}
|
||||
|
||||
public void SelectAllMouseCommmand(TextArea textArea)
|
||||
{
|
||||
ApplicationCommands.SelectAll.Execute(null, textArea);
|
||||
}
|
||||
|
||||
// Undo Status is not given back to disable it's item in ContextFlyout; therefore it's not being used yet.
|
||||
public void UndoMouseCommmand(TextArea textArea)
|
||||
{
|
||||
ApplicationCommands.Undo.Execute(null, textArea);
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче