Eclipse Platform
Release 3.1

org.eclipse.jface.bindings.keys
Class KeySequenceText

java.lang.Object
  extended byorg.eclipse.jface.bindings.keys.KeySequenceText

public final class KeySequenceText
extends Object

A wrapper around the SWT text widget that traps literal key presses and converts them into key sequences for display. There are two types of key strokes that are displayed: complete and incomplete. A complete key stroke is one with a natural key, while an incomplete one has no natural key. Incomplete key strokes are only displayed until they are made complete or their component key presses are released.

Since:
3.1

Field Summary
static int INFINITE
          The special integer value for the maximum number of strokes indicating that an infinite number should be allowed.
static List TRAPPED_KEYS
          The keys trapped by this widget.
 
Constructor Summary
KeySequenceText(Text wrappedText)
          Constructs an instance of KeySequenceTextField with the text field to use.
 
Method Summary
 void clear()
          Clears the text field and resets all the internal values.
 KeySequence getKeySequence()
          An accessor for the KeySequence that corresponds to the current state of the text field.
 int getKeyStrokeLimit()
          Returns the maximum number of strokes that are permitted in this widget at one time.
 void insert(KeyStroke stroke)
          Inserts the key stroke at the current insertion point.
 void setKeySequence(KeySequence newKeySequence)
           A mutator for the key sequence stored within this widget.
 void setKeyStrokeLimit(int keyStrokeLimit)
          A mutator for the maximum number of strokes that are permitted in this widget at one time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INFINITE

public static final int INFINITE
The special integer value for the maximum number of strokes indicating that an infinite number should be allowed.

See Also:
Constant Field Values

TRAPPED_KEYS

public static final List TRAPPED_KEYS
The keys trapped by this widget. This list is guaranteed to be roughly accurate. Perfection is not possible, as SWT does not export traversal keys as constants.

Constructor Detail

KeySequenceText

public KeySequenceText(Text wrappedText)
Constructs an instance of KeySequenceTextField with the text field to use. If the platform is carbon (MacOS X), then the font is set to be the same font used to display accelerators in the menus.

Parameters:
wrappedText - The text widget to wrap; must not be null.
Method Detail

clear

public void clear()
Clears the text field and resets all the internal values.


getKeySequence

public KeySequence getKeySequence()
An accessor for the KeySequence that corresponds to the current state of the text field. This includes incomplete strokes.

Returns:
The key sequence representation; never null.

insert

public void insert(KeyStroke stroke)
Inserts the key stroke at the current insertion point. This does a regular delete and insert, as if the key had been pressed.

Parameters:
stroke - The key stroke to insert; must not be null.

setKeySequence

public void setKeySequence(KeySequence newKeySequence)

A mutator for the key sequence stored within this widget. The text and caret position are updated.

All sequences are limited to maxStrokes number of strokes in length. If there are already that number of strokes, then it does not show incomplete strokes, and does not keep track of them.

Parameters:
newKeySequence - The new key sequence for this widget; may be null if none.

getKeyStrokeLimit

public int getKeyStrokeLimit()
Returns the maximum number of strokes that are permitted in this widget at one time.

Returns:
The maximum number of strokes; will be a positive integer or INFINITE.

setKeyStrokeLimit

public void setKeyStrokeLimit(int keyStrokeLimit)
A mutator for the maximum number of strokes that are permitted in this widget at one time.

Parameters:
keyStrokeLimit - The maximum number of strokes; must be a positive integer or INFINITE.

Eclipse Platform
Release 3.1

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2005. All rights reserved.