mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
UI/Qt: Enable basic IME keyboard input for WebContentView
This makes dead keys work (e.g. typing ' and e results in é).
This commit is contained in:
parent
4a42c97f4d
commit
7e57cc7b09
Notes:
github-actions[bot]
2024-08-12 16:28:26 +00:00
Author: https://github.com/gmta Commit: https://github.com/LadybirdBrowser/ladybird/commit/7e57cc7b090 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1046 Reviewed-by: https://github.com/tcl3 ✅
2 changed files with 17 additions and 1 deletions
|
@ -36,7 +36,6 @@
|
|||
#include <QCursor>
|
||||
#include <QGuiApplication>
|
||||
#include <QIcon>
|
||||
#include <QLineEdit>
|
||||
#include <QMimeData>
|
||||
#include <QMouseEvent>
|
||||
#include <QPaintEvent>
|
||||
|
@ -60,6 +59,7 @@ WebContentView::WebContentView(QWidget* window, RefPtr<WebView::WebContentClient
|
|||
m_client_state.client = parent_client;
|
||||
m_client_state.page_index = page_index;
|
||||
|
||||
setAttribute(Qt::WA_InputMethodEnabled, true);
|
||||
setMouseTracking(true);
|
||||
setAcceptDrops(true);
|
||||
|
||||
|
@ -346,6 +346,20 @@ void WebContentView::keyReleaseEvent(QKeyEvent* event)
|
|||
enqueue_native_event(Web::KeyEvent::Type::KeyUp, *event);
|
||||
}
|
||||
|
||||
void WebContentView::inputMethodEvent(QInputMethodEvent* event)
|
||||
{
|
||||
if (!event->commitString().isEmpty()) {
|
||||
QKeyEvent keyEvent(QEvent::KeyPress, 0, Qt::NoModifier, event->commitString());
|
||||
keyPressEvent(&keyEvent);
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
|
||||
QVariant WebContentView::inputMethodQuery(Qt::InputMethodQuery) const
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void WebContentView::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
if (!m_tooltip_override) {
|
||||
|
|
|
@ -61,6 +61,8 @@ public:
|
|||
virtual void dropEvent(QDropEvent*) override;
|
||||
virtual void keyPressEvent(QKeyEvent* event) override;
|
||||
virtual void keyReleaseEvent(QKeyEvent* event) override;
|
||||
virtual void inputMethodEvent(QInputMethodEvent*) override;
|
||||
virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const override;
|
||||
virtual void showEvent(QShowEvent*) override;
|
||||
virtual void hideEvent(QHideEvent*) override;
|
||||
virtual void focusInEvent(QFocusEvent*) override;
|
||||
|
|
Loading…
Reference in a new issue