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

WPF - Support ALT(Left) and ALT GR (Right) Key. #3769

Merged
merged 1 commit into from Aug 24, 2021
Merged

WPF - Support ALT(Left) and ALT GR (Right) Key. #3769

merged 1 commit into from Aug 24, 2021

Conversation

spinalcord
Copy link
Contributor

@spinalcord spinalcord commented Aug 22, 2021

Fixes:

Summary:

  • Support ALT(Left) and ALT GR (Right) Key.
  • This allows: CTRL+ ALT +[SPECIFIC KEY] to input symbols with WPF (e.g. German keyboard layout)

Changes:

  • Extended a if condition (here) to proof whether the ALT key is pressed and not only ALT GR.

How Has This Been Tested?

  • Tested with a vanilla project and also with the Cef example browser, which is inside the master src.
  • Entered symbols ² ³ { [ ] } } \ @ on certain search engines within Cef example browser

Screenshots (if appropriate):
(Layout: German)
new

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Updated documentation

Checklist:

  • Tested the code(if applicable)
  • Commented my code
  • Changed the documentation(if applicable)
  • New files have a license disclaimer
  • The formatting is consistent with the project (project supports .editorconfig)

Allows also to use the left ALT key, which necessary to input symbols e.g. german keyboard layout.
@AppVeyorBot
Copy link

@amaitland
Copy link
Member

Thanks, in future please target pull requests against master branch. Also please update the pull request title, Update CefBrowserHostWrapper.cpp doesn't describe the change.

Do we need a left and right alt check or can we switch to VK_MENU?

@campersau Thoughts/comments? I know you recently made a refinement to alt gr support.

@spinalcord spinalcord changed the base branch from cefsharp/92 to master August 23, 2021 11:59
@spinalcord spinalcord changed the base branch from master to cefsharp/92 August 23, 2021 12:00
@spinalcord spinalcord changed the title Update CefBrowserHostWrapper.cpp Support ALT(Left) and ALT GR (Right) Key. Aug 23, 2021
@campersau
Copy link
Contributor

1️⃣ AltGr+[Key] was working before.

2️⃣ AltGr+Shift+[Key] was fixed by #3627 (I just ported it back to cef)

3️⃣ (L|R)Strg+Alt+[Key] and (L|R)Strg+Alt+Shift+[Key] will be fixed by this PR, which I have confirmed locally as well.

So all of these combinations are now working in WPF when using a german keyboard layout:

Key (L|R)Strg+Alt+[Key] (L|R)Strg+Alt+Shift+[Key] AltGr+[Key] AltGr+Shift+[Key]
q @ 3️⃣ @ 1️⃣
e 3️⃣ 1️⃣
m µ 3️⃣ µ 1️⃣
2 ² 3️⃣ ² 1️⃣
3 ³ 3️⃣ ³ 1️⃣
7 { 3️⃣ { 1️⃣
8 [ 3️⃣ [ 1️⃣
9 ] 3️⃣ ] 1️⃣
0 } 3️⃣ } 1️⃣
+ ~ 3️⃣ ~ 1️⃣
< | 3️⃣ | 1️⃣
ß \ 3️⃣ 3️⃣ \ 1️⃣ 2️⃣

Instead of checking for both VK_LMENU and VK_RMENU checking only for VK_MENU also worked in my tests.

This PR could then also be backported: https://bitbucket.org/chromiumembedded/cef/src/cfdec92624a82fa59119e0aeb2d4744978f0c9c8/tests/cefclient/browser/osr_window_win.cc#lines-796

@spinalcord FYI the screencapture shows WinForms browser instead of WPF.

@spinalcord
Copy link
Contributor Author

I updated the screenshot.

@amaitland amaitland changed the title Support ALT(Left) and ALT GR (Right) Key. WPF - Support ALT(Left) and ALT GR (Right) Key. Aug 23, 2021
@amaitland amaitland added the wpf label Aug 23, 2021
@amaitland
Copy link
Member

Instead of checking for both VK_LMENU and VK_RMENU checking only for VK_MENU also worked in my tests.

@campersau Thanks, sounds like we can simply check for VK_MENU

This PR could then also be backported: https://bitbucket.org/chromiumembedded/cef/src/cfdec92624a82fa59119e0aeb2d4744978f0c9c8/tests/cefclient/browser/osr_window_win.cc#lines-796

Can you clarify what you are referring to? The CefSharp code is structured slightly differently and the IsKeyDown check only happens for KEYEVENT_CHAR currently.

@campersau
Copy link
Contributor

@amaitland I think they are logical equal because of the lines above this. The main difference is that our call to set the event.modifiers comes earlier and thus we can put all the special handling inside the same else (keyEvent.type = KEYEVENT_CHAR) path whereas cef needs another check for event.type == KEYEVENT_CHAR because the event.modifiers are set later.
https://bitbucket.org/chromiumembedded/cef/src/cfdec92624a82fa59119e0aeb2d4744978f0c9c8/tests/cefclient/browser/osr_window_win.cc#lines-786:796

image

@amaitland amaitland merged commit 017aeec into cefsharp:cefsharp/92 Aug 24, 2021
amaitland pushed a commit that referenced this pull request Aug 24, 2021
Allows also to use the left ALT key, which necessary to input symbols e.g. german keyboard layout.
amaitland added a commit that referenced this pull request Aug 24, 2021
amaitland added a commit that referenced this pull request Aug 24, 2021
@amaitland amaitland added this to the 93.1.x milestone Aug 24, 2021
@amaitland
Copy link
Member

Merged into master in commit b86aa00

Switched to using VK_MENU in commit e00b1ce

Assigning this to the 93 milestone.

Looking at the Chromium source and I think it might be worth looking at implementing a simplified version of PlatformKeyMap::UsesAltGraph so the code path is only run for supported keyboard layouts.

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.

None yet

4 participants