Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qplatforminputcontext.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5#include <qguiapplication.h>
6#include <QRect>
7#include "private/qkeymapper_p.h"
8#include "private/qhighdpiscaling_p.h"
9#include <qpa/qplatforminputcontext_p.h>
10
11#include <QtGui/qtransform.h>
12
14
49{
50}
51
56{
57}
58
63{
64 return false;
65}
66
73{
74 Q_UNUSED(capability);
75 return true;
76}
77
83{
84}
85
87{
88}
89
93void QPlatformInputContext::update(Qt::InputMethodQueries)
94{
95}
96
103{
104 Q_UNUSED(cursorPosition);
105 // Default behavior for simple ephemeral input contexts. Some
106 // complex input contexts should not be reset here.
107 if (action == QInputMethod::Click)
108 reset();
109}
110
118{
120 return false;
121}
122
128{
129 return QRectF();
130}
131
138{
140}
141
147{
148 return false;
149}
150
157{
159}
160
165{
166}
167
172{
173}
174
179{
180 return false;
181}
182
189{
191}
192
194{
196}
197
199{
201}
202
204{
206}
207
209{
211}
212
218{
219 Q_UNUSED(object);
220}
221
226{
228}
229
231
233{
235}
236
242void QPlatformInputContext::setSelectionOnFocusObject(const QPointF &nativeAnchorPos, const QPointF &nativeCursorPos)
243{
244 QObject *focus = qApp->focusObject();
245 if (!focus)
246 return;
247
248 QWindow *window = qApp->focusWindow();
249 const QPointF &anchorPos = QHighDpi::fromNativePixels(nativeAnchorPos, window);
250 const QPointF &cursorPos = QHighDpi::fromNativePixels(nativeCursorPos, window);
251
253 const QTransform mapToLocal = im->inputItemTransform().inverted();
254 bool success;
255 int anchor = QInputMethod::queryFocusObject(Qt::ImCursorPosition, anchorPos * mapToLocal).toInt(&success);
256 if (success) {
257 int cursor = QInputMethod::queryFocusObject(Qt::ImCursorPosition, cursorPos * mapToLocal).toInt(&success);
258 if (success) {
259 if (anchor == cursor && anchorPos != cursorPos)
260 return;
263 QInputMethodEvent event(QString(), imAttributes);
265 }
266 }
267}
268
275{
278 const QTransform mapToLocal = im->inputItemTransform().inverted();
279 return im->queryFocusObject(query, mapToLocal.map(position));
280}
281
289{
291 const QRectF deviceIndependentRectangle = im->inputItemTransform().mapRect(im->inputItemRectangle());
292 return QHighDpi::toNativePixels(deviceIndependentRectangle, QGuiApplication::focusWindow());
293}
294
302{
305}
306
314{
317}
318
326{
329}
330
338{
341}
342
344
345#include "moc_qplatforminputcontext.cpp"
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
\inmodule QtCore
Definition qcoreevent.h:45
static QWindow * focusWindow()
Returns the QWindow that receives events tied to focus, such as key events.
static QInputMethod * inputMethod()
returns the input method.
The QInputMethodEvent class provides parameters for input method events.
Definition qevent.h:624
The QInputMethod class provides access to the active text input method.
Action
Indicates the kind of action performed by the user.
void animatingChanged()
static QVariant queryFocusObject(Qt::InputMethodQuery query, const QVariant &argument)
Send query to the current focus object with parameters argument and return the result.
void inputDirectionChanged(Qt::LayoutDirection newDirection)
QRectF inputItemRectangle() const
QTransform inputItemTransform() const
Returns the transformation from input item coordinates to the window coordinates.
void visibleChanged()
void keyboardRectangleChanged()
void localeChanged()
QLocale keyboardInputLocale
Qt::LayoutDirection keyboardInputDirection
Definition qlist.h:74
void append(parameter_type t)
Definition qlist.h:441
\inmodule QtCore
Definition qobject.h:90
static void setInputMethodAccepted(bool accepted)
virtual bool isInputPanelVisible() const
Returns input panel visibility status.
virtual bool isAnimating() const
This function can be reimplemented to return true whenever input method is animating shown or hidden.
bool inputMethodAccepted() const
Returns true if current focus object supports input method events.
static QRectF anchorRectangle()
QPlatformInputContext::anchorRectangle.
virtual QLocale locale() const
void emitInputDirectionChanged(Qt::LayoutDirection newDirection)
void emitAnimatingChanged()
Active QPlatformInputContext is responsible for providing animating property to QInputMethod.
virtual bool hasCapability(Capability capability) const
Returns whether the implementation supports capability.
void emitInputPanelVisibleChanged()
Active QPlatformInputContext is responsible for providing visible property to QInputMethod.
virtual void update(Qt::InputMethodQueries)
Notification on editor updates.
static void setSelectionOnFocusObject(const QPointF &anchorPos, const QPointF &cursorPos)
QPlatformInputContext::setSelectionOnFocusObject.
static QVariant queryFocusObject(Qt::InputMethodQuery query, QPointF position)
QPlatformInputContext::queryFocusObject.
virtual bool filterEvent(const QEvent *event)
This function can be reimplemented to filter input events.
static QRectF keyboardRectangle()
QPlatformInputContext::keyboardRectangle.
virtual void setFocusObject(QObject *object)
This virtual method gets called to notify updated focus to object.
static QRectF inputItemClipRectangle()
QPlatformInputContext::inputItemClipRectangle.
virtual void invokeAction(QInputMethod::Action, int cursorPosition)
Called when the word currently being composed in the input item is tapped by the user.
virtual bool isValid() const
Returns input context validity.
void emitKeyboardRectChanged()
Active QPlatformInputContext is responsible for providing keyboardRectangle property to QInputMethod.
virtual void reset()
Method to be called when input method needs to be reset.
static QRectF cursorRectangle()
QPlatformInputContext::cursorRectangle.
static QRectF inputItemRectangle()
QPlatformInputContext::inputItemRectangle.
virtual void showInputPanel()
Request to show input panel.
virtual Qt::LayoutDirection inputDirection() const
virtual void hideInputPanel()
Request to hide input panel.
virtual QRectF keyboardRect() const
This function can be reimplemented to return virtual keyboard rectangle in currently active window co...
\inmodule QtCore\reentrant
Definition qpoint.h:214
\inmodule QtCore\reentrant
Definition qrect.h:483
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
The QTransform class specifies 2D transformations of a coordinate system.
Definition qtransform.h:20
QPoint map(const QPoint &p) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QTransform inverted(bool *invertible=nullptr) const
Returns an inverted copy of this matrix.
QRect mapRect(const QRect &) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
\inmodule QtCore
Definition qvariant.h:64
int toInt(bool *ok=nullptr) const
Returns the variant as an int if the variant has userType() \l QMetaType::Int, \l QMetaType::Bool,...
\inmodule QtGui
Definition qwindow.h:63
bool focus
[0]
QCursor cursor
T toNativePixels(const T &value, const C *context)
T fromNativePixels(const T &value, const C *context)
Combined button and popup list for selecting options.
InputMethodQuery
@ ImCursorPosition
LayoutDirection
#define qApp
QKeyMapperPrivate * qt_keymapper_private()
struct _cl_event * event
GLenum query
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define emit
#define Q_UNUSED(x)
aWidget window() -> setWindowTitle("New Window Title")
[2]