Programmer's Guide > Programming and Scripting Techniques > Events > Event Types > ADocumentEvent Module
  
ADocumentEvent Module
The ADocumentEvent extension to the Event interface includes the following event types:
DocumentCreated
The DocumentCreated event occurs after a document is constructed and before any document instance startup files are executed. This event type is similar to the ACL document create callback. However, the ACL document create callback is called after document instance startup files are executed; the DocumentCreated event is called before the startup files are executed.
It is impossible to register a DocumentCreated event listener in a Document object. If the Document object exists, the document has already been created. DocumentCreated event listeners need to be registered in the Application object.
The detail attribute indicates whether the document is empty or not:
0: if the document is constructed from a source file.
1: if the document is empty.
Bubbles: Yes
Cancelable: No
Context Info: detail
DocumentClosed
The DocumentClosed event occurs when a document is destroyed. This event is similar to the ACL document destroy callback.
Bubbles: Yes
Cancelable: No
Context Info: None
DocumentLoad
The DocumentLoad event occurs when a document is loaded into a window frame and all document instance startup files have been executed. This event is similar to ACL editfilehook hook.
When a new window frame is launched, a DocumentLoad event will be dispatched for the document displayed in the new window frame.
A window frame can have more than one view. A DocumentLoad event will only be dispatched if a document is loaded into a window frame and the document does not already have a view in that window frame.
A document can be loaded into two or more different window frames. A DocumentLoad event will be dispatched when a document is loaded into a window frame event if the same document is already displayed in another window frame.
relatedWindow specifies the window frame into which the document is loaded.
Bubbles: Yes
Cancelable: No
Context Info: relatedWindow
DocumentUnload
The DocumentUnload event occurs when a document is unloaded from a window frame. There is no ACL callback equivalent for this event.
A DocumentUnload event will only be dispatched if a document is unloaded from a window frame and the document does not have another view in that window frame.
relatedWindow specifies the window frame from which the document is unloaded. relatedWindow is not set if the window frame is also being destroyed.
Bubbles: Yes
Cancelable: No
Context Info: relatedWindow if the window frame still exists. Otherwise, null.
DocumentSaving
The DocumentSaving event occurs when the user saves a document. This event type covers ACL document save and saveas callbacks. The write command does not cause any ACL callbacks to be called, but it triggers the DocumentSaving event.
This event type is cancelable. If an event listener calls the preventDefault method, the save will be canceled. The user can cancel the save and call the ADocumentSave method in the event listener to save the document. This is useful when some actions need to be done before or after the save.
The targetURI specifies the path the document is saved in. The targetEncoding specifies the encoding the document is saved in.
The detail indicates the command that caused the event:
0: if the event is caused by a save command.
1: if the event is caused by a saveas command.
2: if the event is caused by a write command.
Bubbles: Yes
Cancelable: No
Context Info: targetURI, targetEncoding, detail