Skip to content

Commit 01e8b2f

Browse files
authored
Fix the context menu on TextBox (#60)
1 parent f643432 commit 01e8b2f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/MacOS.Avalonia.Theme/Controls/TextBox.axaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,25 @@
3131
</ThemeVariantScope>
3232
</Design.PreviewWith>
3333

34+
<MenuFlyout x:Key="DefaultTextBoxContextFlyout">
35+
<MenuItem Header="{DynamicResource StringTextFlyoutCutText}" Command="{Binding $parent[TextBox].Cut}"
36+
IsEnabled="{Binding $parent[TextBox].CanCut}" InputGesture="{x:Static TextBox.CutGesture}" />
37+
<MenuItem Header="{DynamicResource StringTextFlyoutCopyText}" Command="{Binding $parent[TextBox].Copy}"
38+
IsEnabled="{Binding $parent[TextBox].CanCopy}" InputGesture="{x:Static TextBox.CopyGesture}" />
39+
<MenuItem Header="{DynamicResource StringTextFlyoutPasteText}" Command="{Binding $parent[TextBox].Paste}"
40+
IsEnabled="{Binding $parent[TextBox].CanPaste}" InputGesture="{x:Static TextBox.PasteGesture}" />
41+
</MenuFlyout>
42+
<MenuFlyout x:Key="HorizontalTextBoxContextFlyout"
43+
FlyoutPresenterTheme="{StaticResource HorizontalMenuFlyoutPresenter}"
44+
ItemContainerTheme="{StaticResource HorizontalMenuItem}">
45+
<MenuItem Header="{DynamicResource StringTextFlyoutCutText}" Command="{Binding $parent[TextBox].Cut}"
46+
IsEnabled="{Binding $parent[TextBox].CanCut}" IsVisible="{Binding $parent[TextBox].CanCut}" />
47+
<MenuItem Header="{DynamicResource StringTextFlyoutCopyText}" Command="{Binding $parent[TextBox].Copy}"
48+
IsEnabled="{Binding $parent[TextBox].CanCopy}" IsVisible="{Binding $parent[TextBox].CanCopy}" />
49+
<MenuItem Header="{DynamicResource StringTextFlyoutPasteText}" Command="{Binding $parent[TextBox].Paste}"
50+
IsEnabled="{Binding $parent[TextBox].CanPaste}" />
51+
</MenuFlyout>
52+
3453
<ControlTheme x:Key="FluentTextBoxButton" TargetType="Button">
3554
<Setter Property="Focusable" Value="False" />
3655
<Setter Property="Padding" Value="0" />
@@ -90,6 +109,8 @@
90109
<Setter Property="MinWidth" Value="{DynamicResource TextControlThemeMinWidth}" />
91110
<Setter Property="FocusAdorner" Value="{x:Null}" />
92111
<Setter Property="ScrollViewer.IsScrollChainingEnabled" Value="True" />
112+
<Setter Property="ContextFlyout"
113+
Value="{OnFormFactor Desktop={StaticResource DefaultTextBoxContextFlyout}, Mobile={StaticResource HorizontalTextBoxContextFlyout}}" />
93114
<Setter Property="ScrollViewer.AllowAutoHide" Value="False" />
94115
<Setter Property="Template">
95116
<ControlTemplate>

0 commit comments

Comments
 (0)