processEvent method

bool processEvent(
  1. WxEvent event
)

Central place for all event processing. Once an event has been created by the system or a user event from any new code, it needs to be processed by this function in the respective window (or other class deriving from WxEvtHandler.

processEvent tries to find a handler for the respective event based on the event type (in the case of system events deriving directly from WxEvent) or the event type and the window ID (in the case of command events deriving from WxCommandEvent).

If no handler is found and the event is a WxCommandEvent then this function will go to the parent window's processEvent and looks for an event handler until either a handler is found or a top level window (WxDialog or WxFrame) is reached.

You can define a new event type with wxNewEventType (typically with a new class deriving from WxCommandEvent) in your code and send it for processing here.

Implementation

bool processEvent( WxEvent event )
{
  // special case for size and paint events

  if (event.getEventType() == wxGetPaintEventType()) {
    if (_onPaintFunc != null) {
      _onPaintFunc!( event as WxPaintEvent );
      return true;
    }
    return false;
  }
  if (event.getEventType() == wxGetSizeEventType()) {
    if (_onSizeFunc != null) {
      _onSizeFunc!( event as WxSizeEvent );
      return true;
    }
    return false;
  }

  //  for (final entry in _eventTable) {
  // go backwards to allow overloading
  for (int i = _eventTable.length-1; i >= 0; i--) {
    final entry = _eventTable[i];
    if (entry.matches(event.getEventType(), event.getId())) {
      entry.doCallFunction(event);
      if (!event.getSkipped()) {
        return true;
      } else {
        // unset skip flag again
        event.skip( skip: false );
      }
    }
  }

  if (event is! WxCommandEvent) {
    return false;
  }

  // command events

  if ((this is WxWindow) && (this is! WxTopLevelWindow)) {
      WxWindow window = this as WxWindow;
      WxWindow? parent = window.getParent();
      if (parent != null) {
        if (parent.processEvent(event)) {
          return true;
        }
      }
  }

  return false;
}