mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 15:10:19 +00:00
Ladybird/Qt: Map Enter keypresses to the code point '\n'
Previously, on systems where pressing Enter would generate "\r\n", only the '\r' character was being sent to the event handler. This change ensures consistent behavior across platforms regardless of their native line ending characters.
This commit is contained in:
parent
5a8e82e6ea
commit
8320faf052
Notes:
sideshowbarker
2024-07-17 00:37:23 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/SerenityOS/serenity/commit/8320faf052 Pull-request: https://github.com/SerenityOS/serenity/pull/23084
1 changed files with 7 additions and 1 deletions
|
@ -451,10 +451,16 @@ void WebContentView::keyPressEvent(QKeyEvent* event)
|
|||
return;
|
||||
}
|
||||
|
||||
auto modifiers = get_modifiers_from_qt_keyboard_event(*event);
|
||||
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {
|
||||
// This ensures consistent behavior between systems that treat Enter as '\n' and '\r\n'
|
||||
client().async_key_down(m_client_state.page_index, KeyCode::Key_Return, modifiers, '\n');
|
||||
return;
|
||||
}
|
||||
|
||||
auto text = event->text();
|
||||
auto point = text.isEmpty() ? 0u : event->text()[0].unicode();
|
||||
auto keycode = get_keycode_from_qt_keyboard_event(*event);
|
||||
auto modifiers = get_modifiers_from_qt_keyboard_event(*event);
|
||||
client().async_key_down(m_client_state.page_index, keycode, modifiers, point);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue