-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Add ability to cancel focus change #18373
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
base: master
Are you sure you want to change the base?
Conversation
@@ -159,5 +159,31 @@ public void Control_Focus_Should_Be_Set_Before_FocusedElement_Raises_PropertyCha | |||
|
|||
Assert.Equal(1, propertyChangedRaised); | |||
} | |||
|
|||
[Fact] | |||
public void Cancelled_Focus_Change_Should_Not_Send_Got_Focus_Event() |
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.
Can you add a unit test with focus redirection?
Is it possible by a direct focus in this PR? Or do we need something like this https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.input.gettingfocuseventargs.trysetnewfocusedelement?view=windows-app-sdk-1.6 ?
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.
Added.
You can test this PR using the following package version. |
What does the pull request do?
Adds the following api;
Adds the following events and callbacks to
InputElement
These api allow controls to cancel any focus change that affects them, as long as the toplevel allows. There are situations where cancelling is not allowed, like when the toplevel loses focus.
What is the current behavior?
Focus change can't be cancelled currently. There's no api to lock focus on a control. There are cases where you want to keep keyboard focus on a control while still being able to interact with other controls, like the case of a textbox in a chat app.
What is the updated/expected behavior with this PR?
How was the solution implemented (if it's not obvious)?
Checklist
Breaking changes
Obsoletions / Deprecations
Fixed issues