Page tree
Skip to end of metadata
Go to start of metadata

bool FB::PluginEventSink::HandleEvent ( PluginEvent event,
PluginEventSource source 
)
pure virtual

Called by the browser when a system event needs to be handled, such as a mouse event, a keyboard event, or a drawing event.

The recommended way to implement HandleEvent is with the PLUGINEVENT_TYPE macros, like so:

BEGIN_PLUGIN_EVENT_MAP()
EVENTTYPE_CASE(FB::MouseDownEvent, onMouseDown, FB::PluginWindow)
EVENTTYPE_CASE(FB::MouseUpEvent, onMouseUp, FB::PluginWindow)
EVENTTYPE_CASE(FB::MouseMoveEvent, onMouseMove, FB::PluginWindow)
END_PLUGIN_EVENT_MAP()
  • BEGIN_PLUGIN_EVENT_MAP() will open the HandleEvent function
  • END_PLUGIN_EVENT_MAP() will close the HandleEvent function
  • EVENTTYPE_CASE(eventType, function, eventSourceType) dispatches events of type "eventType" and calls "function" on the current object. The EventSource is casted as "eventSourceType".

If you use these macros, you must also create the matching methods in your class. For example, the methods needed for the map above are:

virtual bool onMouseDown(FB::MouseDownEvent *evt, FB::PluginWindow*);
virtual bool onMouseUp(FB::MouseUpEvent *evt, FB::PluginWindow*);
virtual bool onMouseMove(FB::MouseMoveEvent *evt, FB::PluginWindow*);
Author
Richard Bateman
Parameters
eventPluginEvent to handle
sourceThe PluginEventSource that the event originated from
Returns
true if the event was handled, false if not.

Definition at line 40 of file PluginEventSink.h.

  • No labels