The main key listener.
Processing of keys: (2012-06-17)
Key events are produced by the underlying graphic operation system. Usual they are applied to the widgets of the
operation system graphic. For example, key left and right are used to navigate in a text field.
On system graphic level any widget can have its key listener. Then the keys are applied to it, the listener determines
what to do with keys. Usual the key is applied to the standard behavior of the widget after them.
But the key event may be set to 'do not do it' in the key listener. Then the standard behavior of the key in that widget is prevent.
The action for some keys may be determined for a special widget or widget type in an graphic system independent way.
The
GralWidget.setActionChange(org.vishia.gral.ifc.GralUserAction)
method can be given for any widget.
The
GralUserAction.userActionGui(int, GralWidget, Object...)
will be invoked with the
KeyCode
and the widget reference. But firstly the
#specialKeysOfWidgetType(int, GralWidget)
is called.
This method may be overridden for the widget type. If it returns true, the key code is not applied to any user action,
it is a widget-special key.
If that method returns false or a
GralWidget#getActionChange()
action is not given for this widget,
the key will be applied to the
GralMng.setMainKeyAction(org.vishia.gral.ifc.GralUserAction)
.
In that way a application-global usage of some keys is organized.
If any of the both widget specific or global
GralUserAction.userActionGui(int, GralWidget, Object...)
method
returns true, the key is not used for the widget in the graphic system. In that kind some keys can be blocked
for standard behavior.
class diagramm of usage for example in SWT:
GralWidget <------------|
|
SwtSpecialWidgetKeyListener ----|> SwtKeyListner ----|> swt.KeyListener <------- SwtWidget
+ specialKeysOfWidgetType() |
|<----|
|
GralSpecialWidgetKeyListener ---|> GralKeyListener
+specialKeysOfWidgetType() * keyPressed(key, gralWidg)
* gralWidg.getActionChange().userActionGui(...)
* mng.userMainKeyAction().userActionGui(...)
(See
org.vishia.util.Docu_UML_simpleNotation
)
The implementing graphic system aggregates an instance of this class.
An underived instance is created in the
GralMng.InternalPublic.gralKeyListener
.
This instance can be used as aggregation in all implementing system listeners, if the
#specialKeysOfWidgetType(int, GralWidget)
should not overridden.