mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
Ladybird/WebContentView: Make Tab and Shift+Tab work
These didn't work, for two reasons: 1. Qt swallows all Tab key presses by default. We have to override the event() function in order to receive them. 2. Qt transforms Shift+Tab into a fake "Backtab" key. We have to undo this transformation and send Shift+Tab to WebContent.
This commit is contained in:
parent
c154d94964
commit
195cdb33de
Notes:
sideshowbarker
2024-07-17 11:29:41 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/195cdb33de Pull-request: https://github.com/SerenityOS/serenity/pull/16583 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/linusg
2 changed files with 23 additions and 0 deletions
|
@ -334,6 +334,12 @@ void WebContentView::keyPressEvent(QKeyEvent* event)
|
|||
break;
|
||||
}
|
||||
|
||||
if (event->key() == Qt::Key_Backtab) {
|
||||
// NOTE: Qt transforms Shift+Tab into a "Backtab", so we undo that transformation here.
|
||||
client().async_key_down(KeyCode::Key_Tab, Mod_Shift, '\t');
|
||||
return;
|
||||
}
|
||||
|
||||
auto text = event->text();
|
||||
if (text.isEmpty()) {
|
||||
return;
|
||||
|
@ -919,3 +925,19 @@ void WebContentView::request_repaint()
|
|||
m_client_state.back_bitmap.pending_paints++;
|
||||
client().async_paint(m_client_state.back_bitmap.bitmap->rect().translated(horizontalScrollBar()->value(), verticalScrollBar()->value()), m_client_state.back_bitmap.id);
|
||||
}
|
||||
|
||||
bool WebContentView::event(QEvent* event)
|
||||
{
|
||||
// NOTE: We have to implement event() manually as Qt's focus navigation mechanism
|
||||
// eats all the Tab key presses by default.
|
||||
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
keyPressEvent(static_cast<QKeyEvent*>(event));
|
||||
return true;
|
||||
}
|
||||
if (event->type() == QEvent::KeyRelease) {
|
||||
keyReleaseEvent(static_cast<QKeyEvent*>(event));
|
||||
return true;
|
||||
}
|
||||
return QAbstractScrollArea::event(event);
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@ public:
|
|||
virtual void hideEvent(QHideEvent*) override;
|
||||
virtual void focusInEvent(QFocusEvent*) override;
|
||||
virtual void focusOutEvent(QFocusEvent*) override;
|
||||
virtual bool event(QEvent*) override;
|
||||
|
||||
void debug_request(String const& request, String const& argument);
|
||||
|
||||
|
|
Loading…
Reference in a new issue