org.kde.koala
Class KKey

java.lang.Object
  extended by org.kde.koala.KKey
All Implemented Interfaces:
org.kde.qt.QtSupport

public class KKey
extends java.lang.Object
implements org.kde.qt.QtSupport

A KKey object represents a single key with possible modifiers (Shift, Ctrl, Alt, Win). It can represent both keys which are understood by Qt as well as those which are additionally supported by the underlying system (e.g. X11).

See Also:
KKeyNative, KKeySequence, KShortcut

Field Summary
static int ALT
           
static int CTRL
           
static int MOD_FLAG_COUNT
          The number of flags.
static int QtWIN
           
static int SHIFT
          Flags to represent the modifiers.
static int WIN
           
 
Constructor Summary
  KKey()
          Creates a new null KKey.
protected KKey(java.lang.Class dummy)
           
  KKey(int keyQt)
          Creates a new key for the given Qt key code.
  KKey(int key, int mod)
           
  KKey(KKey key)
          Copy constructor.
  KKey(org.kde.qt.QKeyEvent keyEvent)
          Extracts the key from the given key event.
  KKey(org.kde.qt.QKeySequence keySeq)
          Creates a new key from the first key code of the given key sequence.
  KKey(java.lang.String key)
          Creates a new key from the given description.
 
Method Summary
 void clear()
          Clears the key.
 int compare(KKey key)
          Compares this key with the given KKey object.
 void dispose()
          Delete the wrapped C++ instance ahead of finalize()
protected  void finalize()
          Deletes the wrapped C++ instance
 boolean init(int keyQt)
          Initializes the key with the given Qt key code.
 boolean init(int key, int mod)
           
 boolean init(KKey key)
          Copies the given key.
 boolean init(org.kde.qt.QKeyEvent keyEvent)
          Initializes the key by extracting the code from the given key event.
 boolean init(org.kde.qt.QKeySequence keySeq)
          Initializes the key with the first key code of the given key sequence.
 boolean init(java.lang.String key)
          Initializes the key with the given description.
 boolean isDisposed()
          Has the wrapped C++ instance been deleted?
 boolean isNull()
          Returns true if the key is null (after clear() or empty constructor).
 int keyCodeQt()
          Returns the qt key code.
static java.lang.String modFlagLabel(int f)
          Returns a user-readable representation of the given modifiers.
 int modFlags()
           
static KKey nil()
          Returns a null key.
 boolean op_equals(KKey key)
          Compares the symbol and modifiers of both keys.
 boolean op_lt(KKey key)
          Compares the symbol and modifiers of both keys.
 boolean op_not_equals(KKey key)
          Compares the symbol and modifiers of both keys.
 void simplify()
           
 int sym()
           
 java.lang.String toString()
          Returns a human-readable representation of the key in the form "modifier+key".
 java.lang.String toStringInternal()
          Returns an untranslated text representation of the key in the form "modifier+key", suitable e.g.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MOD_FLAG_COUNT

public static final int MOD_FLAG_COUNT
The number of flags.

See Also:
ModFlag, Constant Field Values

QtWIN

public static final int QtWIN
See Also:
Constant Field Values

SHIFT

public static final int SHIFT
Flags to represent the modifiers. You can combine modifiers by ORing them.

See Also:
Constant Field Values

CTRL

public static final int CTRL
See Also:
Constant Field Values

ALT

public static final int ALT
See Also:
Constant Field Values

WIN

public static final int WIN
See Also:
Constant Field Values
Constructor Detail

KKey

protected KKey(java.lang.Class dummy)

KKey

public KKey()
Creates a new null KKey.

See Also:
clear(), isNull(), #null

KKey

public KKey(int keyQt)
Creates a new key for the given Qt key code.

Parameters:
keyQt - the qt keycode
See Also:
org.kde.qt.Qt#Key

KKey

public KKey(org.kde.qt.QKeySequence keySeq)
Creates a new key from the first key code of the given key sequence.

Parameters:
keySeq - the key sequence that contains the key

KKey

public KKey(org.kde.qt.QKeyEvent keyEvent)
Extracts the key from the given key event.

Parameters:
keyEvent - the key event to get the key from

KKey

public KKey(KKey key)
Copy constructor.


KKey

public KKey(java.lang.String key)
Creates a new key from the given description. The form of the description is "[modifier+[modifier+]]+key", for example "e", "CTRL+q" or "CTRL+ALT+DEL". Allowed modifiers are "SHIFT", "CTRL", "ALT", "WIN" and "META". "WIN" and "META" are equivalent. Modifiers are not case-sensitive.

Parameters:
key - the description of the key
See Also:
KKeyServer#Sym#init

KKey

public KKey(int key,
            int mod)
Method Detail

clear

public void clear()
Clears the key. The key is null after calling this function.

See Also:
isNull()

init

public boolean init(int keyQt)
Initializes the key with the given Qt key code.

Parameters:
keyQt - the qt keycode
Returns:
true if successful, false otherwise
See Also:
org.kde.qt.Qt#Key

init

public boolean init(org.kde.qt.QKeySequence keySeq)
Initializes the key with the first key code of the given key sequence.

Parameters:
keySeq - the key sequence that contains the key
Returns:
true if successful, false otherwise

init

public boolean init(org.kde.qt.QKeyEvent keyEvent)
Initializes the key by extracting the code from the given key event.

Parameters:
keyEvent - the key event to get the key from
Returns:
true if successful, false otherwise

init

public boolean init(KKey key)
Copies the given key.

Parameters:
key - the key to copy
Returns:
true if successful, false otherwise

init

public boolean init(java.lang.String key)
Initializes the key with the given description. The form of the description is "[modifier+[modifier+]]+key", for example "e", "CTRL+q" or "CTRL+ALT+DEL". Allowed modifiers are "SHIFT", "CTRL", "ALT", "WIN" and "META". "WIN" and "META" are equivalent. Modifiers are not case-sensitive.

Parameters:
key - the description of the key
Returns:
true if successful, false otherwise
See Also:
KKeyServer#Sym#init

init

public boolean init(int key,
                    int mod)

isNull

public boolean isNull()
Returns true if the key is null (after clear() or empty constructor).

Returns:
true if the key is null
See Also:
clear(), #null

sym

public int sym()

modFlags

public int modFlags()

compare

public int compare(KKey key)
Compares this key with the given KKey object. Returns a negative number if the given KKey is larger, 0 if they are equal and a positive number this KKey is larger. The returned value is the difference between the symbol or, if the symbols are equal, the difference between the encoded modifiers.

Parameters:
key - the key to compare with this key
Returns:
a negative number if the given KKey is larger, 0 if they are equal and a positive number this KKey is larger

op_equals

public boolean op_equals(KKey key)
Compares the symbol and modifiers of both keys.

See Also:
compare(org.kde.koala.KKey)

op_not_equals

public boolean op_not_equals(KKey key)
Compares the symbol and modifiers of both keys.

See Also:
compare(org.kde.koala.KKey)

op_lt

public boolean op_lt(KKey key)
Compares the symbol and modifiers of both keys.

See Also:
compare(org.kde.koala.KKey)

keyCodeQt

public int keyCodeQt()
Returns the qt key code.

Returns:
the qt key code or 0 if there is no key set.
See Also:
org.kde.qt.Qt#Key

toString

public java.lang.String toString()
Returns a human-readable representation of the key in the form "modifier+key". Note that the representation is localised, use toStringInternal() for cases like saving to configuration files.

Overrides:
toString in class java.lang.Object
Returns:
the string representation of the key
See Also:
toStringInternal()

toStringInternal

public java.lang.String toStringInternal()
Returns an untranslated text representation of the key in the form "modifier+key", suitable e.g. for saving in configuration files.


simplify

public void simplify()

nil

public static KKey nil()
Returns a null key.

Returns:
the null key
See Also:
isNull(), clear()

modFlagLabel

public static java.lang.String modFlagLabel(int f)
Returns a user-readable representation of the given modifiers.

Parameters:
f - the modifiers to convert
Returns:
the string representation of the modifiers

finalize

protected void finalize()
                 throws java.lang.InternalError
Deletes the wrapped C++ instance

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.InternalError

dispose

public void dispose()
Delete the wrapped C++ instance ahead of finalize()


isDisposed

public boolean isDisposed()
Has the wrapped C++ instance been deleted?