Package ej.microui.event.generator

## Class GenericEventGenerator

- java.lang.Object
- - ej.microui.event.EventGenerator
  - - ej.microui.event.generator.GenericEventGenerator

-     public abstract class GenericEventGenerator
      extends EventGenerator

  Generic event generator.

  Generic communication to receive events.

  Since:
    2.0

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `GenericEventGenerator()` |

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected abstract void` | `eventReceived​(int event)` | Called by the default implementation of `eventReceived(int, EventHandler)` when a custom event has been received from the native world.
    `protected void` | `eventReceived​(int event, EventHandler handler)` | Called by MicroUI pump when a custom event has been received from the native world.
    `protected abstract void` | `eventsReceived​(int[] events)` | Called by the default implementation of `eventReceived(int, EventHandler)` when a custom event has been received from the native world.
    `protected void` | `eventsReceived​(int[] events, EventHandler handler)` | Called by MicroUI pump when a custom event has been received from the native world.
    `abstract void` | `setProperty​(String name, String value)` | Called at startup to configure the event generator with the specific properties set in the MicroUI XML file.

    - ### Methods inherited from class ej.microui.event.EventGenerator

      `addToSystemPool, get, get, get, getEventHandler, getEventType, getId, removeFromSystemPool, sendEvent, setEventHandler`

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

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

- - ### Constructor Detail

    - #### GenericEventGenerator

          public GenericEventGenerator()

  - ### Method Detail

    - #### setProperty

          public abstract void setProperty​(String name,
                                           String value)

      Called at startup to configure the event generator with the specific properties set in the MicroUI XML file.
      Parameters:
        `name` - the property name
        `value` - the property value

    - #### eventReceived

          protected void eventReceived​(int event,
                                       @Nullable
                                       EventHandler handler)

      Called by MicroUI pump when a custom event has been received from the native world. The event contains only one 32-bit value. Implementation has to decode the event. Then it can
      - perform any actions according the event (for instance update a model, etc.),
      - or save it, build a standard MicroUI event (see `Event.buildEvent(int, EventGenerator, int)` and send this event to the given event handler.

      The second solution is useful to deport the event management to a global events handler like other events (command, buttons, pointer and states).

      When the handler is the display's event serializer (see `Display.getEventHandler()`) the given handler is the current displayable; it allows to handle the new MicroUI event immediately, without postponing it to the end of the events queue. Otherwise the given handler is the handler returned by `EventGenerator.getEventHandler()`.

      The handler may be `null` when there is no current displayable or when no handler is set on the event generator.

      The default implementation calls `eventReceived(int)`.

      Parameters:
        `event` - the 32-bit custom event value.
        `handler` - the generator's events handler: the current displayable on display, the handler returned by `EventGenerator.getEventHandler()` or `null`.

    - #### eventReceived

          protected abstract void eventReceived​(int event)

      Called by the default implementation of `eventReceived(int, EventHandler)` when a custom event has been received from the native world. The event contains only one 32-bit value.
      Parameters:
        `event` - the 32-bit custom event value.

    - #### eventsReceived

          protected void eventsReceived​(int[] events,
                                        @Nullable
                                        EventHandler handler)

      Called by MicroUI pump when a custom event has been received from the native world. The event contains several 32-bit values.

      See `eventReceived(int, EventHandler)` comment.

      The default implementation calls `eventsReceived(int[])`.

      Parameters:
        `events` - the 32-bit custom event values.
        `handler` - the generator's events handler: the current displayable on display, the handler returned by `EventGenerator.getEventHandler()` or `null`.

    - #### eventsReceived

          protected abstract void eventsReceived​(int[] events)

      Called by the default implementation of `eventReceived(int, EventHandler)` when a custom event has been received from the native world. The event contains several 32-bit values.
      Parameters:
        `events` - the 32-bit custom event values.
      See Also:
        `eventReceived(int)`