Skip to content
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

Prevent accelerator keys to work when typing text #2056

Merged
merged 16 commits into from
Jan 18, 2018

Conversation

joaompneves
Copy link
Contributor

When you have buttons with accelerator keys defined in a window with CefSharp and you press the key of the accelerator while the web view is focused, the key won't be sent to the web view.
Expected the web view to receive the key event when focused.
This pull request reestablishes that behavior.

Ex: If you have a button _Go (the accelerator key is G) and you type G inside the web view, the web view won't get the event.

@joaompneves joaompneves changed the title Prevent accelerators keys to work when typing text Prevent accelerator keys to work when typing text May 29, 2017
@amaitland
Copy link
Member

Please provide an example that can be used for testing.

@amaitland
Copy link
Member

Without looking into this in detail, from a maintenance point of view I'm not keen on adding a third piece of keyboard handling logic, having two is one more than I'd like as it is.

@amaitland
Copy link
Member

I've got no problem with removing the SourceHook and replacing with a higher level WPF implementation.

@joaompneves
Copy link
Contributor Author

Removed SourceHook and ended up with 2 key handling methods, one for key down/up to handle non-textual key presses and another for textual key presses.

}
base.OnTextInput(e);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should base.OnTextInput(e); be base.OnPreviewTextInput(e);?

/// <param name="e">The <see cref="TextCompositionEventArgs"/> instance containing the event data.</param>
protected override void OnPreviewTextInput(TextCompositionEventArgs e)
{
if (browser != null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to check if (!e.Handled)` here, handle the case where an overriding implementation chooses to handle the input.

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@joaompneves
Copy link
Contributor Author

This is now again ready to merge.

@joaompneves
Copy link
Contributor Author

Any plans to merge this PR?

@perlun
Copy link
Member

perlun commented Dec 27, 2017

@amaitland Since you looked at this before, maybe it makes sense that you look at the latest changes as well. (If you don't have time, let me know as usual and we'll try to make it work in other ways.)

@amaitland
Copy link
Member

Firstly it conflicts with the changes proposed in #2103, whilst I like the idea of removing the source hook and having a higher level solution it's unclear if a sourcehook is required to implement IME support. I would hope there are higher level APIs that we can tap into, I just don't have any experience to know one way or the other.

Secondly there's the question of testing, I'm assuming you've deployed this to a sizeable user base? Testing keyboard input is difficult, so many combinations to factor in. If this PR can be passed as production ready then I'm happy to see it merged.

@joaompneves
Copy link
Contributor Author

This change has been deployed and its running for 6 months now.
I didn't make any automatic tests cause its a bit hard to simulate those scenarios in an automatic unit testing environment.

Regarding the IME support, I would like to have support for it, although I think its more important to have the standard keyboard flow handling working correctly and then have IME support.

@amaitland
Copy link
Member

This change has been deployed and its running for 6 months now.

How many users? Are they all using the same locale or different?

Whilst I'm the first to admit the current keyboard implementation has a few problems, it's also pretty stable, it''s rare that someone raises an issue, so that adds to my reluctance in merging.

@perlun Thoughts?

@joaompneves
Copy link
Contributor Author

Around 200 users, as the current software version using this CefSharp version is still in beta stage. In a few weeks/months this user base will grow to thousands as the software reaches other release stages. Currently we have users testing in portuguese and english locales (at least).

@joaompneves
Copy link
Contributor Author

Any plans for this?

@AppVeyorBot
Copy link

@amaitland
Copy link
Member

If you can make the behavior configurable then the risk of merging is trivial and I'm happy to include this. You can default to the new behavior, long as the old is there as a fall back.

@joaompneves
Copy link
Contributor Author

Added the ability to fallback to the old behavior using a property. Please review.

Tested both approaches against: http://en.key-test.ru/

@AppVeyorBot
Copy link

@amaitland amaitland added this to the 63.0.0 milestone Jan 8, 2018
@amaitland
Copy link
Member

Thanks 👍 Assuming this passes basic testing I'll include in the 63 milestone.

@amaitland amaitland merged commit a845e75 into cefsharp:master Jan 18, 2018
amaitland added a commit that referenced this pull request Jan 18, 2018
- Make public so users can implement their own handler (the OSR IME patch can be rewritten as a IWpfKeyboardHandler)
- Formatting for consistency
- Make methods virtual

Follow up to #2056
@amaitland
Copy link
Member

Merged with changes see a245196

Anyone can implement their own IWpfKeyboardHandler, so in the case of #2103 it can easily be integrated implemented in user code.

amaitland pushed a commit to amaitland/CefSharp that referenced this pull request Jan 22, 2018
* Call correct base method and handle text input in case event wasn't handled
* Removed SourceHook method
* Added previous keyboard handling logic and ability to use it through a property
amaitland added a commit to amaitland/CefSharp that referenced this pull request Jan 22, 2018
- Make public so users can implement their own handler (the OSR IME patch can be rewritten as a IWpfKeyboardHandler)
- Formatting for consistency
- Make methods virtual

Follow up to cefsharp#2056
amaitland pushed a commit that referenced this pull request Jan 22, 2018
* Call correct base method and handle text input in case event wasn't handled
* Removed SourceHook method
* Added previous keyboard handling logic and ability to use it through a property

# Conflicts:
#	CefSharp.Wpf/ChromiumWebBrowser.cs
amaitland added a commit that referenced this pull request Jan 22, 2018
- Make public so users can implement their own handler (the OSR IME patch can be rewritten as a IWpfKeyboardHandler)
- Formatting for consistency
- Make methods virtual

Follow up to #2056
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants