Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwasminputcontext.h
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QWASMINPUTCONTEXT_H
6#define QWASMINPUTCONTEXT_H
7
8#include "qwasmwindow.h"
9
10#include <qpa/qplatforminputcontext.h>
11#include <private/qstdweb_p.h>
12#include <QtCore/qloggingcategory.h>
13
14#include <emscripten/bind.h>
15#include <emscripten/html5.h>
16#include <emscripten/emscripten.h>
17
19
20Q_DECLARE_LOGGING_CATEGORY(qLcQpaWasmInputContext)
21
22class QWasmInputContext : public QPlatformInputContext
23{
24 Q_DISABLE_COPY(QWasmInputContext)
25 Q_OBJECT
26public:
27 explicit QWasmInputContext();
28 ~QWasmInputContext() override;
29
30 bool isValid() const override { return true; }
31 void update(Qt::InputMethodQueries) override;
32 void showInputPanel() override;
33 void hideInputPanel() override;
34 void setFocusObject(QObject *object) override;
35
36 const QString preeditString() { return m_preeditString; }
37 void setPreeditString(QString preeditStr);
38 void insertPreedit(int repalcementLength = 0);
39 void commitPreeditAndClear();
40
41 void commitText(const QString &text, int replaceFrom = 0, int replaceLength = 0);
42
43 void focusOnFocusWindow(QWasmWindow::FocusTarget target);
44
45 void inputCallback(emscripten::val event);
46 void compositionEndCallback(emscripten::val event);
47 void compositionStartCallback(emscripten::val event);
48 void compositionUpdateCallback(emscripten::val event);
49 void beforeInputCallback(emscripten::val event);
50
51 bool isActive() { return inputMethodAccepted(); }
52 bool m_ignoreNextInput = false;
53
54private:
55 void updateInputElement();
56
57 struct CompositionRange
58 {
59 int start = 0;
60 int end = 0;
61 bool isValid = false;
62 };
63
64 CompositionRange getFirstRange() const;
65
66 struct ResolvedRange
67 {
68 int replaceFrom = 0;
69 int replaceLength = 0;
70 };
71
72 ResolvedRange resolveRange(const CompositionRange &range) const;
73
74 QString m_preeditString;
75
76 QObject *m_focusObject = nullptr;
77 emscripten::val m_inputElement = emscripten::val::null();
78 emscripten::val m_compositionRange = emscripten::val::null();
79};
80
81QT_END_NAMESPACE
82
83#endif // QWASMINPUTCONTEXT_H
virtual ~QWasmClipboard()
void sendClipboardData(emscripten::val event)
static bool shouldInstallWindowEventHandlers()
void setMimeData(QMimeData *data, QClipboard::Mode mode=QClipboard::Clipboard) override
static void copy(emscripten::val event)
bool supportsMode(QClipboard::Mode mode) const override
QMimeData * mimeData(QClipboard::Mode mode=QClipboard::Clipboard) override
ProcessKeyboardResult processKeyboard(const KeyEvent &event)
static void cut(emscripten::val event)
static void paste(emscripten::val event)
bool ownsMode(QClipboard::Mode mode) const override
static QWasmIntegration * get()
QWasmClipboard * getWasmClipboard()
Combined button and popup list for selecting options.
Definition qwasmdom.h:30
static bool eventTargetsQtWindow(val event)
static void commonCopyEvent(val event)
EventType
Definition qwasmevent.h:23