Package org.zkoss.zk.ui.util

## Interface EventInterceptor

-     public interface EventInterceptor

  The event interceptor used to intercept the processing of events.

  To register an event interceptor to a desktop, invoke `Desktop.addListener(java.lang.Object)`. To register an event intercepter to a configuration, invoke `Configuration.addListener(java.lang.Class<?>)`.

  Since:
    3.0.0
  Author:
    tomyeh

- - ### Method Summary

    All Methods Instance Methods Default Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `default void` | `afterProcessEvent​(Event event)` | Called after processing an event.
    `default Event` | `beforePostEvent​(Event event)` | Called before posting an event (with `Events.postEvent(org.zkoss.zk.ui.event.Event)`).
    `default Event` | `beforeProcessEvent​(Event event)` | Called before processing an event.
    `default Event` | `beforeSendEvent​(Event event)` | Called before sending an event (with `Events.sendEvent(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event)`).

- - ### Method Detail

    - #### beforeSendEvent

          default Event beforeSendEvent​(Event event)

      Called before sending an event (with `Events.sendEvent(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event)`).

      If this method throws an exception, it will abort the execution and shows an error message to the end user (unless it is cleaned up by `EventThreadCleanup`).

      Parameters:
        `event` - the event being sent
      Returns:
        the event to be sent (so it is usually the same event passed by the event argument). If null, the event is dropped. Note: multiple interceptors might be registered, and the returned value of an interceptor will be used for the following interceptor.

    - #### beforePostEvent

          default Event beforePostEvent​(Event event)

      Called before posting an event (with `Events.postEvent(org.zkoss.zk.ui.event.Event)`).

      If this method throws an exception, it will abort the execution and shows an error message to the end user (unless it is cleaned up by `EventThreadCleanup`).

      Parameters:
        `event` - the event being posted
      Returns:
        the event to be posted (so it is usually the same event passed by the event argument). If null, the event is dropped. Note: multiple interceptors might be registered, and the returned value of an interceptor will be used for the following interceptor.

    - #### beforeProcessEvent

          default Event beforeProcessEvent​(Event event)

      Called before processing an event. By processing, we mean handing over the event to the event listeners and handlers.

      Note: it executes in the event processing thread, so you can update the desktop whatever you need. For example, you might create a highlighted window and return null to prevent the user from accessing, if the system is too busy.

      If this method throws an exception, it will abort the execution and shows an error message to the end user (unless it is cleaned up by `EventThreadCleanup`).

      Parameters:
        `event` - the event being processed
      Returns:
        the event to be processed (so it is usually the same event passed by the event argument). If null, the event is dropped. Note: multiple interceptors might be registered, and the returned value of an interceptor will be used for the following interceptor.

    - #### afterProcessEvent

          default void afterProcessEvent​(Event event)

      Called after processing an event. By processing, we mean handing over the event to the event listeners and handlers.

      If this method throws an exception, it will abort the execution and shows an error message to the end user (unless it is cleaned up by `EventThreadCleanup`).

      Parameters:
        `event` - the event being processed