Events

From Apache OpenOffice Wiki
< Documentation‎ | DevGuide
Revision as of 11:59, 1 November 2007 by Jsc (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search



Events are notifications that you can register as listeners. This concept is actually expressed by registration or unregistration methods for the broadcaster, listener interfaces for the listener and event structures for the event.

Naming

If an object broadcasts a certain event, it offers a pair of methods like addEventNameListener() and removeEventNameListener(). This scheme conforms to the naming scheme of JavaBeans and does not mean that the implementation keeps track of a separate list for each event.

The event methods of the listener interface use the past tense form of the verb that specifies the event, usually in combination with the subject to which it applies, for example, mouseDragged(). For events which are notified before the event actually happens, the method begins with notify, for example, notifyTermination(). Event methods for prohibited events start with the prefix approve, for example, approveTermination().

Usage

Use events if other, previously unknown objects have to be notified about status changes in your object.

Normally, the methods add...Listener() and remove...Listener() have a single argument. The type of argument is an interface derived from com.sun.star.lang.XEventListener.

The event is a struct derived from com.sun.star.lang.EventObject, therefore this struct contains the source of the event.

Content on this page is licensed under the Public Documentation License (PDL).
Personal tools