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

[BUG]: AltGr key modifier not working #208

Closed
Klarso-IvoBurkart opened this issue Jan 16, 2023 · 9 comments
Closed

[BUG]: AltGr key modifier not working #208

Klarso-IvoBurkart opened this issue Jan 16, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@Klarso-IvoBurkart
Copy link

Describe the bug 【Bug描述】

The AltGr key modifier is not working in CEFView-Widgets, making it impossible for some characters to be entered by keyboard depending on key layout. Example would be '[' or '@' on Germany layout.

To Reproduce 【复现步骤】

  1. Create a programm with a QCefView
  2. Open google.com
  3. Try to enter a character that needs AltGr
  4. Character won't appear

Expected behavior 【正确的预期行为】

All characters are inputable

Screenshots 【截图】

...

Environment 【BUG产生的环境】

  • OSR/NCW Mode: OSR
  • OS & Version: Windows
  • Qt Version: 5.15.2
  • CEF Version: 102.0.10+gf249b2e+chromium-102.0.5005.115

Additional context 【更多额外信息】

...

@tishion tishion added the bug Something isn't working label Jan 16, 2023
@tishion
Copy link
Member

tishion commented Jan 16, 2023

i believe this problem was caused by this piece of code

QCefViewPrivate::onViewKeyEvent(QKeyEvent* event)
{
//#if defined(CEF_USE_OSR)
if (isOSRModeEnabled_) {
if (!pCefBrowser_)
return;
// qDebug("==== onViewKeyEvent:key=%d, nativeVirtualKey=0x%02x, nativeScanCode=0x%02x, modifiers=0x%08x, "
// "nativeModifiers=0x%08x, text=%s",
// (Qt::Key)(event->key()),
// event->nativeVirtualKey(),
// event->nativeScanCode(),
// (quint32)(event->modifiers()),
// event->nativeModifiers(),
// event->text().toStdString().c_str());
CefKeyEvent e;
MapQKeyEventToCefKeyEvent(event, e);
// QEvent::KeyRelease - send key release event
if (event->type() == QEvent::KeyRelease) {
e.type = KEYEVENT_KEYUP;
pCefBrowser_->GetHost()->SendKeyEvent(e);
return;
}
// QEvent::KeyPress - send key down event
e.type = KEYEVENT_RAWKEYDOWN;
pCefBrowser_->GetHost()->SendKeyEvent(e);
// send key char event
if (ShouldSendKeyCharEvent(event)) {
AdjustCefKeyCharEvent(event, e);
e.type = KEYEVENT_CHAR;
pCefBrowser_->GetHost()->SendKeyEvent(e);
}
}
//#endif
}

but need further investigating

@JohannesMunk
Copy link

When you are investigating this, please also consider changing this line to support further flags/keys being set:

if (((scan_res >> 8) & 0xFF) == (2 | 4)) {

For reference see:
https://bitbucket.org/chromiumembedded/cef/pull-requests/377

@tishion
Copy link
Member

tishion commented Jan 21, 2023

@JohannesMunk @JohannesMunk I think it will work now.

@JohannesMunk
Copy link

JohannesMunk commented Jan 21, 2023

@tishion Thank you for investigating!! Indeed {}, [] and @ work as expected - <AltGr> seems to work! BUT: All other keys don't work properly anymore. If I press <A> it behaves like <Ctrl>+<A>. Most other characters wont appear, cursor keys don't work. I don't understand how your code change would cause this.

@tishion
Copy link
Member

tishion commented Jan 21, 2023 via email

@tishion
Copy link
Member

tishion commented Jan 21, 2023

@tishion Thank you for investigating!! Indeed {}, [] and @ work as expected - <AltGr> seems to work! BUT: All other keys don't work properly anymore. If I press <A> it behaves like <Ctrl>+<A>. Most other characters wont appear, cursor keys don't work. I don't understand how your code change would cause this.

please refer to this PR
#212

@JohannesMunk
Copy link

I think I found it: Your return statement moved inside the if. If you move it back outside everything works as expected! Thx a lot!

@tishion
Copy link
Member

tishion commented Jan 21, 2023 via email

@tishion
Copy link
Member

tishion commented Jan 21, 2023

Fixed and i am closing this. thanks

@tishion tishion closed this as completed Jan 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants