ImSurroundingText,
ImCurrentSelection,
ImMaximumTextLength,
- ImAnchorPosition
+ ImAnchorPosition,
+ ImHints
};
enum InputMethodHint {
Expose = 208,
+ InputMethodQuery = 209,
+
// 512 reserved for Qt Jambi's MetaCall event
// 513 reserved for Qt Jambi's DeleteOnMainThread event
\sa replacementStart(), setCommitString()
*/
+
+/*! \class QInputMethodQueryEvent
+
+ This event is sent by the input context to input objects.
+
+ It is used by the
+ input method to query a set of properties of the object to be
+ able to support complex input method operations as support for
+ surrounding text and reconversions.
+
+ query() specifies which property is queried.
+
+ The object should call setValue() on the event to fill in the requested
+ data before calling accept().
+*/
+QInputMethodQueryEvent::QInputMethodQueryEvent(Qt::InputMethodQuery query)
+ : QEvent(InputMethodQuery),
+ m_query(query)
+{
+}
+
+QInputMethodQueryEvent::~QInputMethodQueryEvent()
+{
+}
+
+/*!
+ \fn Qt::InputMethodQuery QInputMethodQueryEvent::query() const
+
+ returns the type of data queried.
+*/
+
+/*!
+ \fn QVariant QInputMethodQueryEvent::value() const
+
+ returns the value set by the receiving object. Mainly used by the input method.
+
+ \sa setValue()
+*/
+
+/*!
+ \fn QVariant QInputMethodQueryEvent::setValue()
+
+ Used by the receiving object to set the value requested by query().
+
+ \sa setValue()
+*/
+
#ifndef QT_NO_TABLETEVENT
/*!
int replace_from;
int replace_length;
};
+
+class Q_GUI_EXPORT QInputMethodQueryEvent : public QEvent
+{
+public:
+ QInputMethodQueryEvent(Qt::InputMethodQuery query);
+ ~QInputMethodQueryEvent();
+
+ Qt::InputMethodQuery query() const { return m_query; }
+
+ void setValue(const QVariant &v) { m_value = v; }
+ QVariant value() const { return m_value; }
+private:
+ Qt::InputMethodQuery m_query;
+ QVariant m_value;
+};
+
#endif // QT_NO_INPUTMETHOD
#ifndef QT_NO_DRAGANDDROP
inputMethodEvent((QInputMethodEvent *) event);
break;
+ case QEvent::InputMethodQuery:
+ if (testAttribute(Qt::WA_InputMethodEnabled)) {
+ QInputMethodQueryEvent *query = static_cast<QInputMethodQueryEvent *>(event);
+ QVariant v = inputMethodQuery(query->query());
+
+ if (query->query() == Qt::ImMicroFocus) {
+ QRect r = v.toRect();
+ v = QRect(mapToGlobal(r.topLeft()), r.size());
+ }
+
+ query->setValue(v);
+ query->accept();
+ break;
+ }
+
case QEvent::PolishRequest:
ensurePolished();
break;
case Qt::ImAnchorPosition:
// Fallback.
return inputMethodQuery(Qt::ImCursorPosition);
+ case Qt::ImHints:
+ return (int)inputMethodHints();
default:
return QVariant();
}