-
Notifications
You must be signed in to change notification settings - Fork 9k
Implement custom text context menus to fix crashes #18854
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
7c01c15 to
6770ace
Compare
| <Setter Property="ContextFlyout"> | ||
| <Setter.Value> | ||
| <mtu:TextMenuFlyout /> | ||
| </Setter.Value> | ||
| </Setter> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to do this app-wide? This here fixes almost all occurrences of selectable text, thankfully.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the only thing I can think of is doing it similar to above, but without an x:Key value, so it would apply it to all the textboxes. Like this:
<!--- BODGY: <reason> --->
<Style BasedOn="{StaticResource DefaultTextBoxStyle}"
TargetType="TextBox">
<Setter Property="ContextFlyout">
<Setter.Value>
<mtu:TextMenuFlyout />
</Setter.Value>
</Setter>
</Style>At the bug bash today, I think Dustin also suggested trying to add it at the App.xaml layer or something like that (probably the XAML file you import WinUI 2).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I may do this another time, if anything. My backlog of urgent work got a little long so I need to cut it short. 🙈
carlos-zamora
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this fix #18246 too?
| <Setter Property="ContextFlyout"> | ||
| <Setter.Value> | ||
| <mtu:TextMenuFlyout /> | ||
| </Setter.Value> | ||
| </Setter> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the only thing I can think of is doing it similar to above, but without an x:Key value, so it would apply it to all the textboxes. Like this:
<!--- BODGY: <reason> --->
<Style BasedOn="{StaticResource DefaultTextBoxStyle}"
TargetType="TextBox">
<Setter Property="ContextFlyout">
<Setter.Value>
<mtu:TextMenuFlyout />
</Setter.Value>
</Setter>
</Style>At the bug bash today, I think Dustin also suggested trying to add it at the App.xaml layer or something like that (probably the XAML file you import WinUI 2).
| <ItemGroup> | ||
| <PRIResource Include="Resources\en-US\Resources.resw" /> | ||
| </ItemGroup> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double-checking: Just en-US?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but the <OCResourceDirectory> key was missing.
| @@ -0,0 +1,35 @@ | |||
| #pragma once | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #pragma once | |
| // Copyright (c) Microsoft Corporation. | |
| // Licensed under the MIT license. | |
| #pragma once |
Probably also worth adding the BODGY comment here and referencing the GH issue for historical reasons.
| @@ -0,0 +1,201 @@ | |||
| #include "pch.h" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #include "pch.h" | |
| // Copyright (c) Microsoft Corporation. | |
| // Licensed under the MIT license. | |
| #include "pch.h" |
| // > Common group of selectable controls with common actions | ||
| // > The I in MIDL stands for... | ||
| // No common interface. | ||
| if (const auto box = target.try_as<NumberBox>()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about ComboBox with IsEditable=True?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like we don't use those yet. I wonder if it's worth adding support for that in advance...
carlos-zamora
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Know if this fixes #18246 too?
|
I'll wait for the Canary build and test (and close) it then. Theoretically it should be fixed. |
This works around a bug in WinUI where it creates a single context menu/flyout for text elements per thread, not per `XamlRoot`, similar to many other areas. Since the `XamlRoot` cannot change after creation, this means that once you've opened the flyout, you're locked into that window (= XAML root) forever. You can't open the flyout in another window and once you've closed that window, you can't open it anywhere at all. Closes #18599 * Flies out right click in the * About dialog ✅ * Search dialog ✅ * Word delimiters setting ✅ * Launch size setting ✅ * Across two windows ✅ (cherry picked from commit 076746a) Service-Card-Id: PVTI_lADOAF3p4s4Axadtzgd5l-U Service-Version: 1.23
This works around a bug in WinUI where it creates a single context menu/flyout for text elements per thread, not per
XamlRoot, similar to many other areas. Since theXamlRootcannot change after creation, this means that once you've opened the flyout, you're locked into that window (= XAML root) forever. You can't open the flyout in another window and once you've closed that window, you can't open it anywhere at all.Closes #18599
Validation Steps Performed