You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.



XP Event Loop Interfaces

By Travis Bogard
Last Modified: 9-2-99


 Below are the interfaces that are used to interact with the XP Event Loop.  To create or find an event loop one should use the nsINativeApp interface provided by the nsCNativeApp component.
 

  • nsIEventLoop - Represents a single Event Loop and provides methods for interacting with it.  This interface exposes methods for high level interaction with the event loop through a simple Run() function.  It also provides access to low level interaction if you wish to manually build your own loop in an XP Manner.  The low level functions should be avoided for building an event loop as they are not nearly as efficient as using the Run() method.
  • nsPIEventLoop - This interface is used internally to allow the creator of the event loop to interact with the event loop through an interface.  This interface is not for public consumption and should not be used by anyone that isn't directly responsible for the creation or management of the event loop.
  • nsIEvent - nsIEvent serves as an XP wrapper around native events.  This interface is what all the XP code deals with when it is talking about an event.  From this interface clients wishing to view platform specific data can call the provided GetNativeData() function (There is also a SetNativeData() for setting).  It should be noted that this returned data is platform specific.  It is also a direct pointer to the data being held internally and should therefore not be used past the life of the reference to nsIEvent.
  • nsIEventFilter - This, much like nsIEvent does for events, serves as an XP wrapper around native event filters.  From this interface clients wishing to get or set a platform specific filter can call the provided GetNativeData() or SetNativeData() function.  It should be noted that this returned data is platform specific.  The Get version also returns a direct pointer to the data being held internally and should therefore not be used past the life of the reference to nsIEventFilter.

  • nsIDispatchListener and nsITranslateListener - These interfaces allow you to call the default provided Run() function from the nsIEventLoop interface, but still retain the ability to interject variations of the events being processed.  In nearly all cases this should provide all the needed control that an app may need to avoid writing it's own event loop using the low level functions of nsIEventLoop.  It is very important to try and use these interfaces instead of rolling your own event loop as the efficiency and performance is far greater with Run().  These interfaces are completely optional and should not be passed in if you do not need to watch or change the flow of the event loop.