Qt 4.8
Public Functions | Static Public Functions | Protected Functions | Private Functions | Properties | List of all members
QMacInputContext Class Reference

#include <qmacinputcontext_p.h>

Inheritance diagram for QMacInputContext:
QInputContext QObject

Public Functions

virtual QString identifierName ()
 This function must be implemented in any subclasses to return the identifier name of the input method. More...
 
virtual bool isComposing () const
 This function indicates whether InputMethodStart event had been sent to the current focus widget. More...
 
virtual QString language ()
 This function must be implemented in any subclasses to return a language code (e. More...
 
QWidgetlastFocusWidget () const
 
EventRef lastKeydownEvent ()
 
 QMacInputContext (QObject *parent=0)
 
virtual void reset ()
 This function can be reimplemented in a subclass to reset the state of the input method. More...
 
virtual void setFocusWidget (QWidget *w)
 Sets the widget that has an input focus for this input context. More...
 
void setLastKeydownEvent (EventRef)
 
virtual ~QMacInputContext ()
 
- Public Functions inherited from QInputContext
virtual QList< QAction * > actions ()
 This is a preliminary interface for Qt 4. More...
 
virtual bool filterEvent (const QEvent *event)
 This function can be reimplemented in a subclass to filter input events. More...
 
QWidgetfocusWidget () const
 Returns the widget that has an input focus for this input context. More...
 
virtual QFont font () const
 Returns the font of the current input widget. More...
 
 QInputContext (QObject *parent=0)
 Constructs an input context with the given parent. More...
 
void sendEvent (const QInputMethodEvent &event)
 Sends an input method event specified by event to the current focus widget. More...
 
QTextFormat standardFormat (StandardFormat s) const
 Returns a QTextFormat object that specifies the format for component s. More...
 
virtual void update ()
 This virtual function is called when a state in the focus widget has changed. More...
 
virtual void widgetDestroyed (QWidget *w)
 This virtual function is called when the specified widget is destroyed. More...
 
virtual bool x11FilterEvent (QWidget *keywidget, XEvent *event)
 This function may be overridden only if input method is depending on X11 and you need raw XEvent. More...
 
virtual ~QInputContext ()
 Destroys the input context. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Static Public Functions

static void cleanup ()
 
static OSStatus globalEventProcessor (EventHandlerCallRef, EventRef, void *)
 
static void initialize ()
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 

Protected Functions

void mouseHandler (int pos, QMouseEvent *)
 This function can be reimplemented in a subclass to handle mouse press, release, double-click, and move events within the preedit text. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 

Private Functions

void createTextDocument ()
 

Properties

bool composing
 
QString currentText
 
EventRef keydownEvent
 
QWidgetlastFocusWid
 
bool recursionGuard
 
TSMDocumentID textDocument
 

Additional Inherited Members

- Public Types inherited from QInputContext
enum  StandardFormat { PreeditFormat, SelectionFormat }
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 62 of file qmacinputcontext_p.h.

Constructors and Destructors

◆ QMacInputContext()

QMacInputContext::QMacInputContext ( QObject parent = 0)
explicit

Definition at line 61 of file qmacinputcontext_mac.cpp.

62  : QInputContext(parent), composing(false), recursionGuard(false), textDocument(0),
64 {
65 // createTextDocument();
66 }
TSMDocumentID textDocument
QInputContext(QObject *parent=0)
Constructs an input context with the given parent.

◆ ~QMacInputContext()

QMacInputContext::~QMacInputContext ( )
virtual

Definition at line 68 of file qmacinputcontext_mac.cpp.

69 {
70 #ifndef QT_MAC_USE_COCOA
71  if(textDocument)
72  DeleteTSMDocument(textDocument);
73 #endif
74 }
TSMDocumentID textDocument

Functions

◆ cleanup()

void QMacInputContext::cleanup ( )
static

Definition at line 183 of file qmacinputcontext_mac.cpp.

Referenced by qt_cleanup().

184 {
185 #ifndef QT_MAC_USE_COCOA
186  if(input_proc_handler) {
187  RemoveEventHandler(input_proc_handler);
188  input_proc_handler = 0;
189  }
191  DisposeEventHandlerUPP(input_proc_handlerUPP);
193  }
194 #endif
195 }
static EventHandlerRef input_proc_handler
static EventHandlerUPP input_proc_handlerUPP

◆ createTextDocument()

void QMacInputContext::createTextDocument ( )
private

Definition at line 77 of file qmacinputcontext_mac.cpp.

Referenced by reset(), and setFocusWidget().

78 {
79 #ifndef QT_MAC_USE_COCOA
80  if(!textDocument) {
81  InterfaceTypeList itl = { kUnicodeDocument };
82  NewTSMDocument(1, itl, &textDocument, SRefCon(this));
83  }
84 #endif
85 }
TSMDocumentID textDocument

◆ globalEventProcessor()

OSStatus QMacInputContext::globalEventProcessor ( EventHandlerCallRef  ,
EventRef  event,
void *   
)
static

Definition at line 208 of file qmacinputcontext_mac.cpp.

Referenced by initialize().

209 {
210 #ifndef QT_MAC_USE_COCOA
211  QScopedLoopLevelCounter loopLevelCounter(QApplicationPrivate::instance()->threadData);
212 
213  SRefCon refcon = 0;
214  GetEventParameter(event, kEventParamTextInputSendRefCon, typeRefCon, 0,
215  sizeof(refcon), 0, &refcon);
216  QMacInputContext *context = reinterpret_cast<QMacInputContext*>(refcon);
217 
218  bool handled_event=true;
219  UInt32 ekind = GetEventKind(event), eclass = GetEventClass(event);
220  switch(eclass) {
221  case kEventClassTextInput: {
222  handled_event = false;
224  bool canCompose = widget && (!context || widget->inputContext() == context)
225  && !(widget->inputMethodHints() & Qt::ImhDigitsOnly
227  || widget->inputMethodHints() & Qt::ImhHiddenText);
228  if(!canCompose) {
229  handled_event = false;
230  } else if(ekind == kEventTextInputOffsetToPos) {
232  handled_event = false;
233  break;
234  }
235 
237  QPoint mp(widget->mapToGlobal(QPoint(mr.topLeft())));
238  Point pt;
239  pt.h = mp.x();
240  pt.v = mp.y() + mr.height();
241  SetEventParameter(event, kEventParamTextInputReplyPoint, typeQDPoint,
242  sizeof(pt), &pt);
243  handled_event = true;
244  } else if(ekind == kEventTextInputUpdateActiveInputArea) {
246  handled_event = false;
247  break;
248  }
249 
250  if (context->recursionGuard)
251  break;
252 
253  ByteCount unilen = 0;
254  GetEventParameter(event, kEventParamTextInputSendText, typeUnicodeText,
255  0, 0, &unilen, 0);
256  UniChar *unicode = (UniChar*)NewPtr(unilen);
257  GetEventParameter(event, kEventParamTextInputSendText, typeUnicodeText,
258  0, unilen, 0, unicode);
259  QString text((QChar*)unicode, unilen / sizeof(UniChar));
260  DisposePtr((char*)unicode);
261 
262  ByteCount fixed_length = 0;
263  GetEventParameter(event, kEventParamTextInputSendFixLen, typeByteCount, 0,
264  sizeof(fixed_length), 0, &fixed_length);
265  if(fixed_length == ULONG_MAX || fixed_length == unilen) {
268  context->currentText = QString();
269  qt_sendSpontaneousEvent(context->focusWidget(), &e);
270  handled_event = true;
271  context->reset();
272  } else {
273  ByteCount rngSize = 0;
274  OSStatus err = GetEventParameter(event, kEventParamTextInputSendHiliteRng, typeTextRangeArray, 0,
275  0, &rngSize, 0);
276  QVarLengthArray<TextRangeArray> highlight(rngSize);
277  if (noErr == err) {
278  err = GetEventParameter(event, kEventParamTextInputSendHiliteRng, typeTextRangeArray, 0,
279  rngSize, &rngSize, highlight.data());
280  }
281  context->composing = true;
282  if(fixed_length > 0) {
283  const int qFixedLength = fixed_length / sizeof(UniChar);
286  qFixedLength, text.length()-qFixedLength,
288  QInputMethodEvent e(text, attrs);
289  context->currentText = text;
290  e.setCommitString(text.left(qFixedLength), 0, qFixedLength);
291  qt_sendSpontaneousEvent(widget, &e);
292  handled_event = true;
293  } else {
294  /* Apple's enums that they have removed from Tiger :(
295  enum {
296  kCaretPosition = 1,
297  kRawText = 2,
298  kSelectedRawText = 3,
299  kConvertedText = 4,
300  kSelectedConvertedText = 5,
301  kBlockFillText = 6,
302  kOutlineText = 7,
303  kSelectedText = 8
304  };
305  */
306 #ifndef kConvertedText
307 #define kConvertedText 4
308 #endif
309 #ifndef kCaretPosition
310 #define kCaretPosition 1
311 #endif
313  if (!highlight.isEmpty()) {
314  TextRangeArray *data = highlight.data();
315  for (int i = 0; i < data->fNumOfRanges; ++i) {
316  int start = data->fRange[i].fStart / sizeof(UniChar);
317  int len = (data->fRange[i].fEnd - data->fRange[i].fStart) / sizeof(UniChar);
318  if (data->fRange[i].fHiliteStyle == kCaretPosition) {
320  continue;
321  }
323  format.setFontUnderline(true);
324  if (data->fRange[i].fHiliteStyle == kConvertedText)
325  format.setUnderlineColor(Qt::gray);
326  else
328  attrs << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, start, len, format);
329  }
330  } else {
332  0, text.length(), qt_mac_compose_format());
333  }
334  context->currentText = text;
335  QInputMethodEvent e(text, attrs);
336  qt_sendSpontaneousEvent(widget, &e);
337  handled_event = true;
338  }
339  }
340 #if 0
341  if(!context->composing)
342  handled_event = false;
343 #endif
344 
345  extern bool qt_mac_eat_unicode_key; //qapplication_mac.cpp
346  qt_mac_eat_unicode_key = handled_event;
347  } else if(ekind == kEventTextInputUnicodeForKeyEvent) {
348  EventRef key_ev = 0;
349  GetEventParameter(event, kEventParamTextInputSendKeyboardEvent, typeEventRef, 0,
350  sizeof(key_ev), 0, &key_ev);
351  QString text;
352  ByteCount unilen = 0;
353  if(GetEventParameter(key_ev, kEventParamKeyUnicodes, typeUnicodeText, 0, 0, &unilen, 0) == noErr) {
354  UniChar *unicode = (UniChar*)NewPtr(unilen);
355  GetEventParameter(key_ev, kEventParamKeyUnicodes, typeUnicodeText, 0, unilen, 0, unicode);
356  text = QString((QChar*)unicode, unilen / sizeof(UniChar));
357  DisposePtr((char*)unicode);
358  }
359  unsigned char chr = 0;
360  GetEventParameter(key_ev, kEventParamKeyMacCharCodes, typeChar, 0, sizeof(chr), 0, &chr);
361  if(!chr || chr >= 128 || (text.length() > 0 && (text.length() > 1 || text.at(0) != QLatin1Char(chr))))
362  handled_event = !widget->testAttribute(Qt::WA_InputMethodEnabled);
363  QMacInputContext *context = qobject_cast<QMacInputContext*>(qApp->inputContext());
364  if (context && context->lastKeydownEvent()) {
366  0, false);
367  context->setLastKeydownEvent(0);
368  }
369  }
370  break; }
371  default:
372  break;
373  }
374  if(!handled_event) //let the event go through
375  return eventNotHandledErr;
376 #else
377  Q_UNUSED(event);
378 #endif
379  return noErr; //we eat the event
380 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
QPointer< QWidget > widget
The QInputMethodEvent::Attribute class stores an input method attribute.
Definition: qevent.h:441
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void setCommitString(const QString &commitString, int replaceFrom=0, int replaceLength=0)
Sets the commit string to commitString.
Definition: qevent.cpp:2042
static QApplicationPrivate * instance()
virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const
This method is only relevant for input widgets.
Definition: qwidget.cpp:9683
QWidget * focusWidget() const
Returns the widget that has an input focus for this input context.
The QString class provides a Unicode character string.
Definition: qstring.h:83
T * qobject_cast(QObject *object)
Definition: qobject.h:375
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
bool qt_mac_eat_unicode_key
static QWidget * focus_widget
virtual void reset()
This function can be reimplemented in a subclass to reset the state of the input method.
#define kCaretPosition
#define kConvertedText
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
#define qApp
static const char * data(const QByteArray &arr)
void setUnderlineColor(const QColor &color)
Sets the underline color used for the characters with this format to the color specified.
Definition: qtextformat.h:446
EventRef lastKeydownEvent()
void setLastKeydownEvent(EventRef)
bool translateKeyEvent(QWidget *receiver, const MSG &msg, bool grab)
bool qt_sendSpontaneousEvent(QObject *, QEvent *)
static QTextFormat qt_mac_compose_format()
signed long OSStatus
QInputContext * inputContext()
This function returns the QInputContext for this widget.
Definition: qwidget.cpp:474
struct OpaqueEventRef * EventRef
The QInputMethodEvent class provides parameters for input method events.
Definition: qevent.h:431
QRect toRect() const
Returns the variant as a QRect if the variant has type() Rect ; otherwise returns an invalid QRect...
Definition: qvariant.cpp:2416
void setFontUnderline(bool underline)
If underline is true, sets the text format&#39;s font to be underlined; otherwise it is displayed non-und...
Definition: qtextformat.h:432
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QKeyMapperPrivate * qt_keymapper_private()
Definition: qkeymapper.cpp:113
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
Qt::InputMethodHints inputMethodHints
What input method specific hints the widget has.
Definition: qwidget.h:224
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QPoint mapToGlobal(const QPoint &) const
Translates the widget coordinate pos to global screen coordinates.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
#define text
Definition: qobjectdefs.h:80

◆ identifierName()

virtual QString QMacInputContext::identifierName ( )
inlinevirtual

This function must be implemented in any subclasses to return the identifier name of the input method.

Return value is the name to identify and specify input methods for the input method switching mechanism and so on. The name has to be consistent with QInputContextPlugin::keys(). The name has to consist of ASCII characters only.

There are two different names with different responsibility in the input method domain. This function returns one of them. Another name is called 'display name' that stands for the name for endusers appeared in a menu and so on.

See also
QInputContextPlugin::keys(), QInputContextPlugin::displayName()

Implements QInputContext.

Definition at line 72 of file qmacinputcontext_p.h.

72 { return QLatin1String("mac"); }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString

◆ initialize()

void QMacInputContext::initialize ( )
static

Definition at line 170 of file qmacinputcontext_mac.cpp.

Referenced by qt_init().

171 {
172 #ifndef QT_MAC_USE_COCOA
173  if(!input_proc_handler) {
175  InstallEventHandler(GetApplicationEventTarget(), input_proc_handlerUPP,
176  GetEventTypeCount(input_events), input_events,
177  0, &input_proc_handler);
178  }
179 #endif
180 }
static EventTypeSpec input_events[]
static EventHandlerRef input_proc_handler
static OSStatus globalEventProcessor(EventHandlerCallRef, EventRef, void *)
static EventHandlerUPP input_proc_handlerUPP

◆ isComposing()

bool QMacInputContext::isComposing ( ) const
virtual

This function indicates whether InputMethodStart event had been sent to the current focus widget.

It is ensured that an input context can send InputMethodCompose or InputMethodEnd event safely if this function returned true.

The state is automatically being tracked through sendEvent().

See also
sendEvent()

Implements QInputContext.

Definition at line 138 of file qmacinputcontext_mac.cpp.

139 {
140  return composing;
141 }

◆ language()

QString QMacInputContext::language ( )
virtual

This function must be implemented in any subclasses to return a language code (e.

g. "zh_CN", "zh_TW", "zh_HK", "ja", "ko", ...) of the input context. If the input context can handle multiple languages, return the currently used one. The name has to be consistent with QInputContextPlugin::language().

This information will be used by language tagging feature in QInputMethodEvent. It is required to distinguish unified han characters correctly. It enables proper font and character code handling. Suppose CJK-awared multilingual web browser (that automatically modifies fonts in CJK-mixed text) and XML editor (that automatically inserts lang attr).

Implements QInputContext.

Definition at line 88 of file qmacinputcontext_mac.cpp.

89 {
90  return QString();
91 }
The QString class provides a Unicode character string.
Definition: qstring.h:83

◆ lastFocusWidget()

QWidget* QMacInputContext::lastFocusWidget ( ) const
inline

Definition at line 85 of file qmacinputcontext_p.h.

85 { return lastFocusWid; }

◆ lastKeydownEvent()

EventRef QMacInputContext::lastKeydownEvent ( )
inline

Definition at line 83 of file qmacinputcontext_p.h.

Referenced by globalEventProcessor().

83 { return keydownEvent; }

◆ mouseHandler()

void QMacInputContext::mouseHandler ( int  x,
QMouseEvent event 
)
protectedvirtual

This function can be reimplemented in a subclass to handle mouse press, release, double-click, and move events within the preedit text.

You can use the function to implement mouse-oriented user interface such as text selection or popup menu for candidate selection.

The x parameter is the offset within the string that was sent with the InputMethodCompose event. The alteration boundary of x is ensured as character boundary of preedit string accurately.

The event parameter is the event that was sent to the editor widget. The event type is QEvent::MouseButtonPress, QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick or QEvent::MouseMove. The event's button and state indicate the kind of operation that was performed.

Reimplemented from QInputContext.

Definition at line 94 of file qmacinputcontext_mac.cpp.

95 {
96 #ifndef QT_MAC_USE_COCOA
97  if(e->type() != QEvent::MouseButtonPress)
98  return;
99 
100  if (!composing)
101  return;
102  if (pos < 0 || pos > currentText.length())
103  reset();
104  // ##### handle mouse position
105 #else
106  Q_UNUSED(pos);
107  Q_UNUSED(e);
108 #endif
109 }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
virtual void reset()
This function can be reimplemented in a subclass to reset the state of the input method.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ reset()

void QMacInputContext::reset ( )
virtual

This function can be reimplemented in a subclass to reset the state of the input method.

This function is called by several widgets to reset input state. For example, a text widget call this function before inserting a text to make widget ready to accept a text.

Default implementation is sufficient for simple input method. You can override this function to reset external input method engines in complex input method. In the case, call QInputContext::reset() to ensure proper termination of inputting.

In a reimplementation of reset(), you must not send any QInputMethodEvent containing preedit text. You can only commit string and attributes; otherwise, you risk breaking input state consistency.

Implements QInputContext.

Definition at line 120 of file qmacinputcontext_mac.cpp.

Referenced by globalEventProcessor(), and mouseHandler().

121 {
122  if (recursionGuard)
123  return;
124  if (!currentText.isEmpty()){
128  currentText = QString();
129  }
130  recursionGuard = true;
132  composing = false;
133  ActivateTSMDocument(textDocument);
134  FixTSMDocument(textDocument);
135  recursionGuard = false;
136 }
TSMDocumentID textDocument
void setCommitString(const QString &commitString, int replaceFrom=0, int replaceLength=0)
Sets the commit string to commitString.
Definition: qevent.cpp:2042
QWidget * focusWidget() const
Returns the widget that has an input focus for this input context.
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
bool qt_sendSpontaneousEvent(QObject *, QEvent *)
The QInputMethodEvent class provides parameters for input method events.
Definition: qevent.h:431

◆ setFocusWidget()

void QMacInputContext::setFocusWidget ( QWidget widget)
virtual

Sets the widget that has an input focus for this input context.

Warning
Ordinary input methods must not call this function directly.
See also
focusWidget()

Reimplemented from QInputContext.

Definition at line 144 of file qmacinputcontext_mac.cpp.

145 {
146  if (!w)
149 #ifndef QT_MAC_USE_COCOA
150  if(w)
151  ActivateTSMDocument(textDocument);
152  else
153  DeactivateTSMDocument(textDocument);
154 #endif
156 }
TSMDocumentID textDocument
QWidget * focusWidget() const
Returns the widget that has an input focus for this input context.
virtual void setFocusWidget(QWidget *w)
Sets the widget that has an input focus for this input context.

◆ setLastKeydownEvent()

void QMacInputContext::setLastKeydownEvent ( EventRef  event)

Definition at line 197 of file qmacinputcontext_mac.cpp.

Referenced by globalEventProcessor(), and QKeyMapperPrivate::translateKeyEvent().

198 {
199  EventRef tmpEvent = keydownEvent;
201  if (keydownEvent)
202  RetainEvent(keydownEvent);
203  if (tmpEvent)
204  ReleaseEvent(tmpEvent);
205 }
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
struct OpaqueEventRef * EventRef

Properties

◆ composing

bool QMacInputContext::composing
private

Definition at line 89 of file qmacinputcontext_p.h.

Referenced by globalEventProcessor(), isComposing(), mouseHandler(), and reset().

◆ currentText

QString QMacInputContext::currentText
private

Definition at line 92 of file qmacinputcontext_p.h.

Referenced by globalEventProcessor(), mouseHandler(), and reset().

◆ keydownEvent

EventRef QMacInputContext::keydownEvent
private

Definition at line 93 of file qmacinputcontext_p.h.

Referenced by setLastKeydownEvent().

◆ lastFocusWid

QWidget* QMacInputContext::lastFocusWid
private

Definition at line 94 of file qmacinputcontext_p.h.

Referenced by setFocusWidget().

◆ recursionGuard

bool QMacInputContext::recursionGuard
private

Definition at line 90 of file qmacinputcontext_p.h.

Referenced by globalEventProcessor(), and reset().

◆ textDocument

TSMDocumentID QMacInputContext::textDocument
private

Definition at line 91 of file qmacinputcontext_p.h.

Referenced by createTextDocument(), reset(), setFocusWidget(), and ~QMacInputContext().


The documentation for this class was generated from the following files: