File tree 2 files changed +35
-0
lines changed
Avalonia.Base/Input/TextInput
2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,12 @@ public abstract class TextInputMethodClient
64
64
/// </summary>
65
65
public virtual void SetPreeditText ( string ? preeditText ) { }
66
66
67
+ /// <summary>
68
+ /// Execute specific context menu actions
69
+ /// </summary>
70
+ /// <param name="action">The <see cref="ContextMenuAction"/> to perform</param>
71
+ public virtual void ExecuteContextMenuAction ( ContextMenuAction action ) { }
72
+
67
73
/// <summary>
68
74
/// Sets the non-committed input string and cursor offset in that string
69
75
/// </summary>
@@ -101,4 +107,12 @@ protected virtual void RequestReset()
101
107
}
102
108
103
109
public record struct TextSelection ( int Start , int End ) ;
110
+
111
+ public enum ContextMenuAction
112
+ {
113
+ Copy ,
114
+ Cut ,
115
+ Paste ,
116
+ SelectAll
117
+ }
104
118
}
Original file line number Diff line number Diff line change @@ -201,6 +201,27 @@ private static string GetTextLineText(TextLine textLine)
201
201
return lineText ;
202
202
}
203
203
204
+ public override void ExecuteContextMenuAction ( ContextMenuAction action )
205
+ {
206
+ base . ExecuteContextMenuAction ( action ) ;
207
+
208
+ switch ( action )
209
+ {
210
+ case ContextMenuAction . Copy :
211
+ _parent ? . Copy ( ) ;
212
+ break ;
213
+ case ContextMenuAction . Cut :
214
+ _parent ? . Cut ( ) ;
215
+ break ;
216
+ case ContextMenuAction . Paste :
217
+ _parent ? . Paste ( ) ;
218
+ break ;
219
+ case ContextMenuAction . SelectAll :
220
+ _parent ? . SelectAll ( ) ;
221
+ break ;
222
+ }
223
+ }
224
+
204
225
private void OnParentPropertyChanged ( object ? sender , AvaloniaPropertyChangedEventArgs e )
205
226
{
206
227
if ( e . Property == TextBox . TextProperty )
You can’t perform that action at this time.
0 commit comments