Eclipse Platform
Release 4.2

org.eclipse.swt.widgets
Class IME

java.lang.Object
  extended by org.eclipse.swt.widgets.Widget
      extended by org.eclipse.swt.widgets.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:
Sample code and further information
Restriction:
This class is not intended to be subclassed by clients.

Constructor Summary
IME(Canvas parent, int style)
          Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.
 
Method Summary
 int getCaretOffset()
          Returns the offset of the caret from the start of the document.
 int getCommitCount()
          Returns the commit count of the composition.
 int getCompositionOffset()
          Returns the offset of the composition from the start of the document.
 int[] getRanges()
          Returns the ranges for the style that should be applied during the in-line edit session.
 TextStyle[] getStyles()
          Returns the styles for the ranges.
 String getText()
          Returns the composition text.
 boolean getWideCaret()
          Returns true if the caret should be wide, and false otherwise.
 void setCompositionOffset(int offset)
          Sets the offset of the composition from the start of the document.
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkSubclass, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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:
Widget.checkSubclass(), Widget.getStyle()
Method Detail

getCaretOffset

public int getCaretOffset()
Returns the offset of the caret from the start of the document. 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:
getText()

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

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:
getRanges()

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

Eclipse Platform
Release 4.2

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2012. All rights reserved.