Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.gui
Class QInputContext

    java.lang.Object
      com.trolltech.qt.internal.QSignalEmitterInternal
          com.trolltech.qt.QSignalEmitter
              com.trolltech.qt.QtJambiObject
                  com.trolltech.qt.core.QObject
                      com.trolltech.qt.gui.QInputContext

All Implemented Interfaces:
  QtJambiInterface

    public abstract class QInputContext

extends QObject

The QInputContext class abstracts the input method dependent data and composing state. An input method is responsible to input complex text that cannot be inputted via simple keymap. It converts a sequence of input events (typically key events) into a text string through the input method specific converting process. The class of the processes are widely ranging from simple finite state machine to complex text translator that pools a whole paragraph of a text with text editing capability to perform grammar and semantic analysis.

To abstract such different input method specific intermediate information, Qt offers the QInputContext as base class. The concept is well known as 'input context' in the input method domain. an input context is created for a text widget in response to a demand. It is ensured that an input context is prepared for an input method before input to a text widget.

Multiple input contexts that is belonging to a single input method may concurrently coexist. Suppose multi-window text editor. Each text widget of window A and B holds different QInputContext instance which contains different state information such as partially composed text.

## Groups of Functions

Context | Functions
--- | ---
Receiving information | x11FilterEvent(), `filterEvent()`, `mouseHandler()`
Sending back composed text | `sendEvent()`
State change notification | setFocusWidget(), `reset()`
Context information | `identifierName()`, `language()`, `font()`, `isComposing()`

Copyright (C) 2003-2004 immodule for Qt Project. All rights reserved.This file is written to contribute to Nokia under their own license. You may use this file under your Qt license. Following description is copied from their original file headers. Contact immodule-qt@freedesktop.org if any conditions of this licensing are not clear to you.

See also:
  `QInputContextPlugin`, `QInputContextFactory`, and `QApplication::setInputContext()`.

Nested Class Summary
`static class` | `QInputContext.StandardFormat` See also. `standardFormat()`.

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal`

Field Summary

Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`currentSender`

Constructor Summary
`QInputContext()` Constructs an input context with the given `parent`.
`QInputContext(QObject parent)` Constructs an input context with the given `parent`.

Method Summary
`java.util.List` | `actions()` This is a preliminary interface for Qt 4.
`boolean` | `filterEvent(QEvent event)` This function can be reimplemented in a subclass to filter input events.
`QFont` | `font()` Returns the font of the current input widget
`abstract java.lang.String` | `identifierName()` This function must be implemented in any subclasses to return the identifier name of the input method.
`abstract boolean` | `isComposing()` This function indicates whether InputMethodStart event had been sent to the current focus widget.
`abstract java.lang.String` | `language()` This function must be implemented in any subclasses to return a language code (e.
`void` | `mouseHandler(int x, QMouseEvent event)` This function can be reimplemented in a subclass to handle mouse press, release, double-click, and move events within the preedit text.
`abstract void` | `reset()` This function can be reimplemented in a subclass to reset the state of the input method.
`void` | `sendEvent(QInputMethodEvent event)` Sends an input method event specified by `event` to the current focus widget.
`QTextFormat` | `standardFormat(QInputContext.StandardFormat s)` Returns a `QTextFormat` object that specifies the format for component `s`.
`void` | `update()` This virtual function is called when a state in the focus widget has changed.
`void` | `widgetDestroyed(QWidget w)` This virtual function is called when the specified `widget` is destroyed.

Methods inherited from class com.trolltech.qt.core.QObject
`childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty`

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`__qt_signalInitialization`

Methods inherited from class java.lang.Object
`clone, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Constructor Detail

### QInputContext

    public QInputContext()

  Constructs an input context with the given `parent`.

### QInputContext

    public QInputContext(QObject parent)

  Constructs an input context with the given `parent`.

Method Detail

### sendEvent

    public final void sendEvent(QInputMethodEvent event)

  Sends an input method event specified by `event` to the current focus widget. Implementations of QInputContext should call this method to send the generated input method events and not `QApplication::sendEvent()`, as the events might have to get dispatched to a different application on some platforms.

  Some complex input methods route the handling to several child contexts (e.g. to enable language switching). To account for this, QInputContext will check if the parent object is a QInputContext. If yes, it will call the parents `sendEvent()` implementation instead of sending the event directly.

See also:
  `QInputMethodEvent`.

### standardFormat

    public final QTextFormat standardFormat(QInputContext.StandardFormat s)

  Returns a `QTextFormat` object that specifies the format for component `s`.

### actions

    public java.util.List actions()

  This is a preliminary interface for Qt 4.

### filterEvent

    public boolean filterEvent(QEvent event)

  This function can be reimplemented in a subclass to filter input events.

  Return true if the `event` has been consumed. Otherwise, the unfiltered `event` will be forwarded to widgets as ordinary way. Although the input events have accept() and ignore() methods, leave it untouched.

  `event` is currently restricted to `QKeyEvent`. But some input method related events such as `QWheelEvent` or `QTabletEvent` may be added in future.

  The filtering opportunity is always given to the input context as soon as possible. It has to be taken place before any other key event consumers such as eventfilters and accelerators because some input methods require quite various key combination and sequences. It often conflicts with accelerators and so on, so we must give the input context the filtering opportunity first to ensure all input methods work properly regardless of application design.

  Ordinary input methods require discrete key events to work properly, so Qt's key compression is always disabled for any input contexts.

See also:
  `QKeyEvent`, and x11FilterEvent().

### font

    public QFont font()

  Returns the font of the current input widget

### identifierName

    public abstract java.lang.String identifierName()

  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()`, and `QInputContextPlugin::displayName()`.

### isComposing

    public abstract boolean isComposing()

  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()`.

### language

    public abstract java.lang.String language()

  This function must be implemented in any subclasses to return a language code (e. . "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).

### mouseHandler

    public void mouseHandler(int x,
                             QMouseEvent event)

  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::MouseButtonMove. The event's button and state indicate the kind of operation that was performed.

### reset

    public abstract void reset()

  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.

  You must not send any `QInputMethodEvent` except empty InputMethodEnd event using `QInputContext::reset()` at reimplemented `reset()`. It will break input state consistency.

### update

    public void update()

  This virtual function is called when a state in the focus widget has changed. QInputContext can then use `QWidget::inputMethodQuery()` to query the new state of the widget.

### widgetDestroyed

    public void widgetDestroyed(QWidget w)

  This virtual function is called when the specified `widget` is destroyed. The `widget` is a widget on which this input context is installed.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD