org.vishia.gral.base

## Class GralKeyListener

- java.lang.Object
- - org.vishia.gral.base.GralKeyListener

- All Implemented Interfaces:
    GralKeySpecial_ifc

      public class GralKeyListener
      extends java.lang.Object
      implements GralKeySpecial_ifc

  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 `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.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected GralMng` | `mng`
    `static int` | `version` Version, history and license 2011-12-03 Hartmut created.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GralKeyListener(GralMng mng)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `keyPressed(int keyCode, GralWidget_ifc widgi, java.lang.Object widgImpl)`
    `boolean` | `specialKeysOfWidgetType(int key, GralWidget_ifc widgg, java.lang.Object widgImpl)` This method can be overridden by specialized classes of this.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### version

          public static final int version

      Version, history and license
      - 2011-12-03 Hartmut created. Any widget may have the same key listener. It is the baseclass of it and empty yet.
      Copyright/Copyleft: For this source the LGPL Lesser General Public License, published by the Free Software Foundation is valid. It means:
      1. You can use this source without any restriction for any desired purpose.
      2. You can redistribute copies of this source to everybody.
      3. Every user of this source, also the user of redistribute copies with or without payment, must accept this license for further using.
      4. But the LPGL ist not appropriate for a whole software product, if this source is only a part of them. It means, the user must publish this part of source, but don't need to publish the whole source of the own product.
      5. You can study and modify (improve) this source for own using or for redistribution, but you have to license the modified sources likewise under this LGPL Lesser General Public License. You mustn't delete this Copyright/Copyleft inscription in this source file.
      If you are intent to use this sources without publishing its usage, you can get a second license subscribing a special contract with the author.
      See Also:
        Constant Field Values

    - #### mng

          protected final GralMng mng

  - ### Constructor Detail

    - #### GralKeyListener

          public GralKeyListener(GralMng mng)

  - ### Method Detail

    - #### keyPressed

          public boolean keyPressed(int keyCode,
                                    GralWidget_ifc widgi,
                                    java.lang.Object widgImpl)

    - #### specialKeysOfWidgetType

          public boolean specialKeysOfWidgetType(int key,
                                                 GralWidget_ifc widgg,
                                                 java.lang.Object widgImpl)

      Description copied from interface: `GralKeySpecial_ifc`
      This method can be overridden by specialized classes of this. This method is called firstly. Note if a special key should be handled in the `GralWidget#getActionChange()` then this special handling should be programmed in the derived class. If this method returns true, the key is not applied to the action and not applied to the common handling.
      Specified by:
        `specialKeysOfWidgetType` in interface `GralKeySpecial_ifc`
      Returns:
        true if the key is processed.