Next to assigning macros to events, one can monitor events raised by %PRODUCTNAME documents. Application Programming Interface (API) broadcasters are responsible for calling event scripts. Unlike listeners that require to define all supported methods, even if unused, document monitors require only two methods next to hooked event scripts.
Listening to Document Events
- Monitoring is illustrated herewith for Basic and Python languages using object-oriented programming. Assigning OnLoad script, to the Open Document event, suffices to initiate and terminate document event monitoring. menu tab is used to assign either scripts.
- Intercepting events helps setting scripts pre- and post-conditions such as loading and unloading libraries or track script processing in the background. Access2Base Trace module usage is illustrating that second context.
-
With Python
+ Monitoring is illustrated herewith for Basic and Python languages using object-oriented programming. Assigning OnLoad script, to the Open Document event, suffices to initiate and terminate document event monitoring. menu tab is used to assign either scripts.
+ Intercepting events helps setting scripts pre- and post-conditions such as loading and unloading libraries or track script processing in the background. Access2Base.Trace module usage is illustrating that second context.
+
+
With Python
+
+ API;frame.Desktop: Monitoring Document Event
+ API;script.provider.MasterScriptProviderFactory: Monitoring Document Event
+ API;script.provider.XScript: Monitoring Document Event
+ Events monitoring starts from object instantiation and ultimately stops when Python releases the object. Raised events are reported using Access2Base console.
- OnLoad and OnUnload events can be used to respectively set and unset Python programs path. They are described as Open document and Document closed.
+ OnLoad and OnUnload events can be used to respectively set and unset Python programs path. They are described as Open document and Document closed.# -*- coding: utf-8 -*-from __future__ import unicode_literals
@@ -149,9 +149,14 @@
return xScriptMind the misspelled documentEventOccured method that inherits a typo from %PRODUCTNAME Application Programming Interface (API).
- Start application and Close application events can respectively be used to set and to unset Python path for user scripts or %PRODUCTNAME scripts. In a similar fashion, document based Python libraries or modules can be loaded and released using Open document and Document closed events. Refer to Importing Python Modules for more information.
-
With %PRODUCTNAME Basic
- The Onload script is assigned to Open document event using menu tab. Events monitoring starts from the moment a ConsoleLogger object is instantiated and ultimately stops when Basic engine releases it. OnLoad event loads necessary Basic libraries, while caught events are reported using Access2Base.Trace module.
+ Start application and Close application events can respectively be used to set and to unset Python path for user scripts or %PRODUCTNAME scripts. In a similar fashion, document based Python libraries or modules can be loaded and released using Open document and Document closed events. Refer to Importing Python Modules for more information.
+
+
With %PRODUCTNAME Basic
+
+ API;GlobalScope.BasicLibraries
+ Tools;Strings
+
+ The Onload script is assigned to Open document event using menu tab. Events monitoring starts from the moment a ConsoleLogger object is instantiated and ultimately stops when Basic engine releases it. OnLoad event loads necessary Basic libraries, while caught events are reported using Access2Base.Trace module.REM controller.Events moduleOption Explicit
@@ -228,7 +233,11 @@
' Your code for handled events goes hereMind the misspelled _documentEventOccured method that inherits a typo from %PRODUCTNAME Application Programming Interface (API).
-
Discovering Documents Events
+
+
Discovering Documents Events
+
+ API;frame.GlobalEventBroadcaster: Monitoring Document Event
+ The broadcaster API object provides the list of events it is responsible for:
With Python
diff --git a/source/text/sbasic/shared/01040000.xhp b/source/text/sbasic/shared/01040000.xhp
index 182aa39ade..942be5ce68 100644
--- a/source/text/sbasic/shared/01040000.xhp
+++ b/source/text/sbasic/shared/01040000.xhp
@@ -33,6 +33,7 @@
assigning macros to eventsdocuments; eventsevents; assigning macros
+ events; in documentsAPI; XDocumentEventListener