-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Make popup focus stealing configurable. #16642
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In native text box in integration test app. Only implemented for win32 right now. This is to test the two popup behaviors required for native controls: - The context menu needs focus to be transferred to Avalonia - The ToolTip must not transfer focus to Avalonia
By default, if a popup is shown when a native control is focused, focus is transferred back to Avalonia in order for the popup to receive input. If this property is set to false, then the shown popup will not receive input until it receives an interaction which explicitly focuses the popup, such as a mouse click. The effect of this property can be seen in the Embedding tag of the IntegrationTestApp: hovering over the native text box shows an Avalonia `ToolTip` which does not steal focus from the native text box. Right-clicking to open an Avalonia `ContextMenu` does steal focus so the menu items can be selected using the arrow keys. Currently only implemented on a win32.
Only tested on win32 so far.
As can be expected at this point, really.
You can test this PR using the following package version. |
MrJul
reviewed
Sep 30, 2024
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 left a comment regarding the attached property usage.
Other than that, LGTM!
MrJul
approved these changes
Sep 30, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does the pull request do?
#16365 removed focus stealing for popups, but this turns out that completely removing this isn't a good idea. Two example scenarios for focus stealing are:
ToolTip
popups up: in his case, focus should remain in the native text box so the user can continue typing (no stealing)ContextMenu
is shown: in this case, focus should be transferred back to Avalonia to allow them to press the Down arrow to select the first item in the context menu (stealing)I added a test scenario to IntegrationTestApp that shows the two desired behaviors:
ToolTip
ContextMenu
To control this behavior, I added an attached
Popup.TakesFocusFromNativeControl
property, which defaults totrue
(it's attached because you can set it directly onPopup
or on a control that uses a popup - onlyContextMenu
respects this property currently).ToolTip
sets the property tofalse
for its inbuilt popup.I'm not attached to this naming, please feel free to suggest alternatives.
[ ] Implement on X11not in this PR[ ] Implement integration test on macOSCan't get integration tests to work on macOS