Class IME


public class IME extends Widget
Instances of this class represent input method editors. These are typically in-line pre-edit text areas that allow the user to compose characters from Far Eastern languages such as Japanese, Chinese or Korean.
Styles:
(none)
Events:
ImeComposition

IMPORTANT: This class is not intended to be subclassed.

Since:
3.4
See Also:
Restriction:
This class is not intended to be subclassed by clients.
  • Constructor Details

    • IME

      public IME(Canvas parent, int style)
      Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

      The style value is either one of the style constants defined in class SWT which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using the int "|" operator) two or more of those SWT style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.

      Parameters:
      parent - a canvas control which will be the parent of the new instance (cannot be null)
      style - the style of control to construct
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the parent is null
      SWTException -
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
      • ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
      See Also:
  • Method Details

    • getCaretOffset

      public int getCaretOffset()
      Returns the offset of the caret from the start of the document. -1 means that there is currently no active composition. The caret is within the current composition.
      Returns:
      the caret offset
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getCommitCount

      public int getCommitCount()
      Returns the commit count of the composition. This is the number of characters that have been composed. When the commit count is equal to the length of the composition text, then the in-line edit operation is complete.
      Returns:
      the commit count
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
      See Also:
    • getCompositionOffset

      public int getCompositionOffset()
      Returns the offset of the composition from the start of the document. This is the start offset of the composition within the document and in not changed by the input method editor itself during the in-line edit session.
      Returns:
      the offset of the composition
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getRanges

      public int[] getRanges()
      Returns the ranges for the style that should be applied during the in-line edit session.

      The ranges array contains start and end pairs. Each pair refers to the corresponding style in the styles array. For example, the pair that starts at ranges[n] and ends at ranges[n+1] uses the style at styles[n/2] returned by getStyles().

      Returns:
      the ranges for the styles
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
      See Also:
    • getStyles

      public TextStyle[] getStyles()
      Returns the styles for the ranges.

      The ranges array contains start and end pairs. Each pair refers to the corresponding style in the styles array. For example, the pair that starts at ranges[n] and ends at ranges[n+1] uses the style at styles[n/2].

      Returns:
      the ranges for the styles
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
      See Also:
    • getText

      public String getText()
      Returns the composition text.

      The text for an IME is the characters in the widget that are in the current composition. When the commit count is equal to the length of the composition text, then the in-line edit operation is complete.

      Returns:
      the widget text
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getWideCaret

      public boolean getWideCaret()
      Returns true if the caret should be wide, and false otherwise. In some languages, for example Korean, the caret is typically widened to the width of the current character in the in-line edit session.
      Returns:
      the wide caret state
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setCompositionOffset

      public void setCompositionOffset(int offset)
      Sets the offset of the composition from the start of the document. This is the start offset of the composition within the document and in not changed by the input method editor itself during the in-line edit session but may need to be changed by clients of the IME. For example, if during an in-line edit operation, a text editor inserts characters above the IME, then the IME must be informed that the composition offset has changed.
      Parameters:
      offset - the offset of the composition
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver