summaryrefslogtreecommitdiff
path: root/wizards/source/access2base/Utils.xba
diff options
context:
space:
mode:
Diffstat (limited to 'wizards/source/access2base/Utils.xba')
-rw-r--r--wizards/source/access2base/Utils.xba31
1 files changed, 31 insertions, 0 deletions
diff --git a/wizards/source/access2base/Utils.xba b/wizards/source/access2base/Utils.xba
index 79cebb63d0c6..42c0a4b15a24 100644
--- a/wizards/source/access2base/Utils.xba
+++ b/wizards/source/access2base/Utils.xba
@@ -964,6 +964,37 @@ Dim lEnd As Long, vResult As Object
End Function
REM -----------------------------------------------------------------------------------------------------------------------
+Public Function _RegisterDialogEventScript(poObject As Object _
+ , ByVal psEvent As String _
+ , ByVal psListener As String _
+ , ByVal psScriptCode As String _
+ ) As Boolean
+' Register a script event (psEvent) to poObject (Dialog or dialog Control)
+
+Dim oEvents As Object, sEvent As String, sEventName As String, oEvent As Object
+
+ _RegisterDialogEventScript = False
+ If Not _hasUNOMethod(poObject, "getEvents") Then Exit Function
+
+' Remove existing event, if any, than store new script code
+ Set oEvents = poObject.getEvents()
+ sEvent = Utils._GetEventName(psEvent)
+ sEventName = "com.sun.star.awt." & psListener & "::" & sEvent
+ If oEvents.hasByName(sEventName) Then oEvents.removeByName(sEventName)
+ Set oEvent = CreateUnoStruct("com.sun.star.script.ScriptEventDescriptor")
+ With oEvent
+ .ListenerType = psListener
+ .EventMethod = sEvent
+ .ScriptType = "Script" ' Better than "Basic"
+ .ScriptCode = psScriptCode
+ End With
+ oEvents.insertByName(sEventName, oEvent)
+
+ _RegisterDialogEventScript = True
+
+End Function ' _RegisterDialogEventScript V1.8.0
+
+REM -----------------------------------------------------------------------------------------------------------------------
Public Function _RegisterEventScript(poObject As Object _
, ByVal psEvent As String _
, ByVal psListener As String _