1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE script:module PUBLIC
"-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3 <script:module xmlns:
script=
"http://openoffice.org/2000/script" script:
name=
"SF_DialogListener" script:
language=
"StarBasic" script:
moduleType=
"normal">REM =======================================================================================================================
4 REM === The ScriptForge library and its associated libraries are part of the LibreOffice project. ===
5 REM === The SFDialogs library is one of the associated libraries. ===
6 REM === Full documentation is available on https://help.libreoffice.org/ ===
7 REM =======================================================================================================================
12 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
13 ''' SF_Listener
14 ''' ===========
15 ''' The current module is dedicated to the management of dialog control events, triggered by user actions,
16 ''' which are not defined with the Basic IDE
18 ''' Concerned events:
19 ''' TreeControl control type, prefix = _SFEXP_
20 ''' -----------
21 ''' The OnNodeSelected event, triggered when a user selects a node
22 ''' A typical action is to display additional info about the selected item elsewhere in the dialog
23 ''' The OnNodeExpanded event, triggered when a user clicks on the expansion symbol
24 ''' A typical action is to create dynamically a subnode or a subtree below the expanded item
26 ''' PageManager facility, prefix = _SFTAB_
27 ''' -----------
28 ''' Depending on the piloting control(s), next event types are implemented
29 ''' XActionListener: for buttons
30 ''' XItemListener: for listboxes, comboboxes and radio buttons
32 ''' The described events are processed thru UNO listeners
34 ''' "On
" events defined by code, prefix = _SFFOCUS_, _SFKEY_, _SFMOUSE_, _SFMOVE_, _SFITEM_, _SFADJUST_, _SFTEXT_
35 ''' -----------
36 ''' All event types applicable on dialogs and control types
<> TreeControl
37 ''' The events MUST NOT be preset in the Basic IDE
39 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
41 REM ================================================================= DEFINITIONS
43 REM ================================================================== EXCEPTIONS
45 REM ================================================ PUBLIC METHODS (TREECONTROL)
47 REM -----------------------------------------------------------------------------
48 Public Sub _SFEXP_requestChildNodes(Optional ByRef poEvent As Object)
49 ''' Triggered by the OnNodeExpanded event of a tree control
50 ''' The event is triggered thru a com.sun.star.view.XTreeExpansionListener
51 ''' The argument is passed to a user routine stored in the SF_DialogControl instance
52 ''' as a scripting framework URI
54 Dim oControl As Object
' The SF_DialogControl object having triggered the event
56 On Local Error GoTo Catch
' Avoid stopping event scripts
59 ' Ensure there is a node
60 If IsNull(poEvent) Or IsMissing(poEvent) Then Exit Sub
61 If IsNull(poEvent.Node) Then Exit Sub
64 Set oControl = ScriptForge.SF_Services.CreateScriptService(
"SFDialogs.DialogEvent
", poEvent)
65 ScriptForge.SF_Session._ExecuteScript(oControl.OnNodeExpanded, poEvent)
71 End Sub
' SFDialogs.SF_Dialoglistener._SFEXP_requestChildNodes
73 Sub _SFEXP_disposing(ByRef poEvent As Object)
76 Sub _SFEXP_treeExpanding(Optional ByRef poEvent As Object)
79 Sub _SFEXP_treeCollapsing(ByRef poEvent As Object)
82 Sub _SFEXP_treeExpanded(ByRef poEvent As Object)
85 Sub _SFEXP_treeCollapsed(ByRef poEvent As Object)
88 REM -----------------------------------------------------------------------------
89 Public Sub _SFSEL_selectionChanged(Optional ByRef poEvent As Object)
90 ''' Triggered by the OnNodeSelected event of a tree control
91 ''' The event is triggered thru a com.sun.star.view.XSelectionChangeListener
92 ''' The argument is passed to a user routine stored in the SF_DialogControl instance
93 ''' as a scripting framework URI
95 ''' Nothing happens if there are several selected nodes or none
97 Dim vSelection As Variant
' Variant, not object !!
98 Dim oControl As Object
' The SF_DialogControl object having triggered the event
100 On Local Error GoTo Catch
' Avoid stopping event scripts
103 ' Ensure there is a selection
104 If IsNull(poEvent) Or IsMissing(poEvent) Then Exit Sub
105 vSelection = poEvent.Source.getSelection()
106 If IsEmpty(vSelection) Or IsArray(vSelection) Then Exit Sub
109 Set oControl = ScriptForge.SF_Services.CreateScriptService(
"SFDialogs.DialogEvent
", poEvent)
110 ScriptForge.SF_Session._ExecuteScript(oControl.OnNodeSelected, poEvent)
116 End Sub
' SFDialogs.SF_Dialoglistener._SFSEL_selectionChanged
118 Sub _SFSEL_disposing(ByRef poEvent As Object)
121 REM ============================================ PUBLIC METHODS (PAGE MANAGEMENT)
123 REM -----------------------------------------------------------------------------
124 Public Sub _SFTAB_actionPerformed(Optional ByRef poEvent As Object)
125 ''' Event triggered by a button configured through the dialog page manager
126 ''' Buttons may be of type TABCONTROL, BACKCONTROL or NEXTCONTROL
128 Dim oControl As Object
' The DialogControl instance having caused the event
129 Dim sName As String
' Control name
130 Dim oDialog As Object
' The parent Dialog instance
131 Dim oPageManager As Object
' An entry in dialog._PageManagement
133 Const BACKCONTROL =
3
134 Const NEXTCONTROL =
4
137 On Local Error GoTo Finally
' Never interrupt !!
138 Set oControl = CreateScriptService(
"DialogEvent
", poEvent)
139 If IsNull(oControl) Then GoTo Finally
142 Set oDialog = oControl.Parent
144 sName = oControl.Name
145 ' Find entry in page manager settings
146 For Each oPageManager In ._PageManagement
147 If oPageManager.ControlName = sName Then
148 Select Case oPageManager.PageMgtType
149 Case TABCONTROL : .Page = oPageManager.PageNumber
150 Case BACKCONTROL : .Page = .Page -
1
151 Case NEXTCONTROL : .Page = .Page +
1
161 End Sub
' SFDialogs.SF_Dialoglistener._SFTAB_actionPerformed
163 REM -----------------------------------------------------------------------------
164 Public Sub _SFTAB_itemStateChanged(Optional ByRef poEvent As Object)
165 ''' Event triggered by a listbox, combobox or radiobutton configured through the dialog page manager
166 ''' Buttons are of type PILOTCONTROL
168 Dim oControl As Object
' The DialogControl instance having caused the event
169 Dim sName As String
' Control name
170 Dim oDialog As Object
' The parent Dialog instance
171 Dim oPageManager As Object
' An entry in dialog._PageManagement
172 Dim lPage As Long
' Actual page number
175 On Local Error GoTo Finally
' Never interrupt !!
176 Set oControl = CreateScriptService(
"DialogEvent
", poEvent)
177 If IsNull(oControl) Then GoTo Finally
180 Set oDialog = oControl.Parent
182 sName = oControl.Name
183 ' Find entry in page manager settings
184 For Each oPageManager In ._PageManagement
185 If oPageManager.ControlName = sName Then
186 lPage = oPageManager.PageNumber
187 If lPage =
0 Then .Page = oControl.ListIndex +
1 Else .Page = lPage
195 End Sub
' SFDialogs.SF_Dialoglistener._SFTAB_itemStateChanged
197 REM -----------------------------------------------------------------------------
198 Public Sub _SFTAB_disposing(Optional ByRef poEvent As Object)
201 REM ========================== PUBLIC METHODS (GENERIC DIALOG AND CONTROL EVENTS)
203 ''' Next methods SIMULATE the behaviour of events set on dialogs and dialog controls
204 ''' in the Events tab of a dialog editing page in the Basic IDE.
205 ''' They are not triggered by events preset in the Basic IDE.
206 ''' They are triggered ONLY when the event has been set by code with one of the OnXxxYyyy properties,
207 ''' like in:
208 ''' dialog.OnActionPerformed =
"vnd....
" ' URI notation
210 REM -----------------------------------------------------------------------------
211 Public Sub _SFACTION_actionPerformed(Optional ByRef poEvent As Object)
212 ''' Triggered by the OnActionPerformed event in a dialog control
213 ''' The event is triggered thru a com.sun.star.awt.XActionListener
214 ''' The argument is passed to a user routine stored in the SF_DialogControl instance
215 ''' as a scripting framework URI
217 _TriggerEvent(
"actionPerformed
", poEvent)
219 End Sub
' SFDialogs.SF_Dialoglistener. _SFACTION_actionPerformed
221 REM -----------------------------------------------------------------------------
222 Public Sub _SFACTION_disposing()
225 REM -----------------------------------------------------------------------------
226 Public Sub _SFADJUST_adjustmentValueChanged(Optional ByRef poEvent As Object)
227 ''' Triggered by the OnAdjustmentValueChanged event in a scrollbar
228 ''' The event is triggered thru a com.sun.star.awt.XAdjustmentListener
229 ''' The argument is passed to a user routine stored in the SF_DialogControl instance
230 ''' as a scripting framework URI
232 _TriggerEvent(
"adjustmentValueChanged
", poEvent)
234 End Sub
' SFDialogs.SF_Dialoglistener. _SFADJUST_adjustmentValueChanged
236 REM -----------------------------------------------------------------------------
237 Public Sub _SFADJUST_disposing()
240 REM -----------------------------------------------------------------------------
241 Public Sub _SFFOCUS_focusGained(Optional ByRef poEvent As Object)
242 ''' Triggered by the OnFocusGained event in a dialog or dialog control
243 ''' The event is triggered thru a com.sun.star.awt.XFocusListener
244 ''' The argument is passed to a user routine stored in the SF_Dialog or SF_DialogControl instance
245 ''' as a scripting framework URI
247 _TriggerEvent(
"focusGained
", poEvent)
249 End Sub
' SFDialogs.SF_Dialoglistener._SFFOCUS_focusGained
251 REM -----------------------------------------------------------------------------
252 Public Sub _SFFOCUS_focusLost(Optional ByRef poEvent As Object)
253 ''' Triggered by the OnFocusLost event in a dialog or dialog control
254 ''' The event is triggered thru a com.sun.star.awt.XFocusListener
255 ''' The argument is passed to a user routine stored in the SF_Dialog or SF_DialogControl instance
256 ''' as a scripting framework URI
258 _TriggerEvent(
"focusLost
", poEvent)
260 End Sub
' SFDialogs.SF_Dialoglistener._SFFOCUS_focusLost
262 REM -----------------------------------------------------------------------------
263 Public Sub _SFFOCUS_disposing()
266 REM -----------------------------------------------------------------------------
267 Public Sub _SFITEM_itemStateChanged(Optional ByRef poEvent As Object)
268 ''' Triggered by the OnItemStateChanged event in a dialog control
269 ''' The event is triggered thru a com.sun.star.awt.XItemListener
270 ''' The argument is passed to a user routine stored in the SF_DialogControl instance
271 ''' as a scripting framework URI
273 _TriggerEvent(
"itemStateChanged
", poEvent)
275 End Sub
' SFDialogs.SF_Dialoglistener. _SFACTION_actionPerformed
277 REM -----------------------------------------------------------------------------
278 Public Sub _SFITEM_disposing()
281 REM -----------------------------------------------------------------------------
282 Public Sub _SFKEY_keyPressed(Optional ByRef poEvent As Object)
283 ''' Triggered by the OnKeyPressed event in a dialog or dialog control
284 ''' The event is triggered thru a com.sun.star.awt.XKeyListener
285 ''' The argument is passed to a user routine stored in the SF_Dialog or SF_DialogControl instance
286 ''' as a scripting framework URI
288 _TriggerEvent(
"keyPressed
", poEvent)
290 End Sub
' SFDialogs.SF_Dialoglistener._SFKEY_keyPressed
292 REM -----------------------------------------------------------------------------
293 Public Sub _SFKEY_keyReleased(Optional ByRef poEvent As Object)
294 ''' Triggered by the OnKeyReleased event in a dialog or dialog control
295 ''' The event is triggered thru a com.sun.star.awt.XKeyListener
296 ''' The argument is passed to a user routine stored in the SF_Dialog or SF_DialogControl instance
297 ''' as a scripting framework URI
299 _TriggerEvent(
"keyReleased
", poEvent)
301 End Sub
' SFDialogs.SF_Dialoglistener._SFKEY_keyReleased
303 REM -----------------------------------------------------------------------------
304 Public Sub _SFKEY_disposing()
307 REM -----------------------------------------------------------------------------
308 Public Sub _SFMOUSE_mouseEntered(Optional ByRef poEvent As Object)
309 ''' Triggered by the OnMouseEntered event in a dialog or dialog control
310 ''' The event is triggered thru a com.sun.star.awt.XMouseListener
311 ''' The argument is passed to a user routine stored in the SF_Dialog or SF_DialogControl instance
312 ''' as a scripting framework URI
314 _TriggerEvent(
"mouseEntered
", poEvent)
316 End Sub
' SFDialogs.SF_Dialoglistener._SFMOUSE_mouseEntered
318 REM -----------------------------------------------------------------------------
319 Public Sub _SFMOUSE_mouseExited(Optional ByRef poEvent As Object)
320 ''' Triggered by the OnMouseExited event in a dialog or dialog control
321 ''' The event is triggered thru a com.sun.star.awt.XMouseListener
322 ''' The argument is passed to a user routine stored in the SF_Dialog or SF_DialogControl instance
323 ''' as a scripting framework URI
325 _TriggerEvent(
"mouseExited
", poEvent)
327 End Sub
' SFDialogs.SF_Dialoglistener._SFMOUSE_mouseExited
329 REM -----------------------------------------------------------------------------
330 Public Sub _SFMOUSE_mousePressed(Optional ByRef poEvent As Object)
331 ''' Triggered by the OnMousePressed event in a dialog or dialog control
332 ''' The event is triggered thru a com.sun.star.awt.XMouseListener
333 ''' The argument is passed to a user routine stored in the SF_Dialog or SF_DialogControl instance
334 ''' as a scripting framework URI
336 _TriggerEvent(
"mousePressed
", poEvent)
338 End Sub
' SFDialogs.SF_Dialoglistener._SFMOUSE_mousePressed
340 REM -----------------------------------------------------------------------------
341 Public Sub _SFMOUSE_mouseReleased(Optional ByRef poEvent As Object)
342 ''' Triggered by the OnMouseReleased event in a dialog or dialog control
343 ''' The event is triggered thru a com.sun.star.awt.XMouseListener
344 ''' The argument is passed to a user routine stored in the SF_Dialog or SF_DialogControl instance
345 ''' as a scripting framework URI
347 _TriggerEvent(
"mouseReleased
", poEvent)
349 End Sub
' SFDialogs.SF_Dialoglistener._SFMOUSE_mouseReleased
351 REM -----------------------------------------------------------------------------
352 Public Sub _SFMOUSE_disposing()
355 REM -----------------------------------------------------------------------------
356 Public Sub _SFMOVE_mouseDragged(Optional ByRef poEvent As Object)
357 ''' Triggered by the OnMouseDragged event in a dialog or dialog control
358 ''' The event is triggered thru a com.sun.star.awt.XMouseMotionListener
359 ''' The argument is passed to a user routine stored in the SF_Dialog or SF_DialogControl instance
360 ''' as a scripting framework URI
362 _TriggerEvent(
"mouseDragged
", poEvent)
364 End Sub
' SFDialogs.SF_Dialoglistener._SFMOUSE_mouseDragged
366 REM -----------------------------------------------------------------------------
367 Public Sub _SFMOVE_mouseMoved(Optional ByRef poEvent As Object)
368 ''' Triggered by the OnMouseMoved event in a dialog or dialog control
369 ''' The event is triggered thru a com.sun.star.awt.XMouseMotionListener
370 ''' The argument is passed to a user routine stored in the SF_Dialog or SF_DialogControl instance
371 ''' as a scripting framework URI
373 _TriggerEvent(
"mouseMoved
", poEvent)
375 End Sub
' SFDialogs.SF_Dialoglistener._SFMOUSE_mouseMoved
377 REM -----------------------------------------------------------------------------
378 Public Sub _SFMOVE_disposing()
381 REM -----------------------------------------------------------------------------
382 Public Sub _SFTEXT_textChanged(Optional ByRef poEvent As Object)
383 ''' Triggered by the OnTextChanged event in a dialog control
384 ''' The event is triggered thru a com.sun.star.awt.XTextListener
385 ''' The argument is passed to a user routine stored in the SF_DialogControl instance
386 ''' as a scripting framework URI
388 _TriggerEvent(
"textChanged
", poEvent)
390 End Sub
' SFDialogs.SF_Dialoglistener. _SFTEXT_textChanged
392 REM -----------------------------------------------------------------------------
393 Public Sub _SFTEXT_disposing()
396 REM ============================================================= PRIVATE METHODS
398 REM -----------------------------------------------------------------------------
399 Public Function _SetOnProperty(ByRef poInstance As Object _
400 , ByVal psProperty As String _
401 , ByVal psScript As String _
403 ''' Set one of the On properties related to either a SF_Dialog or SF_DialogControl instance
404 ''' Such a property is typically set by next pseudo-code:
405 ''' poInstance.psProperty = psScript
406 ''' It requires a strictly identical nomenclature of internal variables in both classes.
407 ''' Args:
408 ''' poInstance: a SF_Dialog or a SF_DialogControl instance
409 ''' psProperty: one of the applicable On properties (
"OnFocusGained
",
"OnMouseMoved
", ...)
410 ''' psScript: the script to run when the event is triggered
411 ''' When the zero-length string, the trigger is deactivated
413 Dim bSet As Boolean
' Return value
414 Dim oModel As Object
' com.sun.star.awt.XControlModel
415 Dim oView As Object
' com.sun.star.awt.XControl
416 Dim oDialogEvents As Object
' com.sun.star.container.XNameContainer
417 Dim sListener As String
' Applicable listener, depending on property, f.i.
"XMouseListener
"
418 Dim sEventName As String
' Internal event name
419 Dim iCounterIncrement As Integer
' Increment to be applied on listener counter
420 Dim sPrevious As String
' Actual value of script before the change
422 Const cstPrefix =
"com.sun.star.awt.
"
427 If IsNull(poInstance) Or Len(psProperty) =
0 Then GoTo Catch
430 ' Initialize local variables depending on instance type
431 If .ObjectType =
"DIALOG
" Then
432 Set oModel = ._DialogModel
433 Set oView = ._DialogControl
434 Else
' DIALOGCONTROL
435 Set oModel = ._ControlModel
436 Set oView = ._ControlView
438 If IsNull(oModel) Or IsNull(oView) Then GoTo Catch
440 ' Ignore request if an event has been statically preset (in the Basic IDE) with the same name
441 Set oDialogEvents = oModel.getEvents()
442 sListener = ._GetListener(psProperty)
443 sEventName = cstPrefix
& sListener
& "::
" & ._GetEventName(psProperty)
444 If oDialogEvents.hasByName(sEventName) Then GoTo Catch
447 ' Note the target scripts. Compare previous and new values. Fix the increment to be applied on counter
448 Select Case UCase(psProperty)
449 Case UCase(
"OnActionPerformed
")
450 sPrevious = ._OnActionPerformed
451 ._OnActionPerformed = psScript
452 Case UCase(
"OnAdjustmentValueChanged
")
453 sPrevious = ._OnAdjustmentValueChanged
454 ._OnAdjustmentValueChanged = psScript
455 Case UCase(
"OnFocusGained
")
456 sPrevious = ._OnfocusGained
457 ._OnFocusGained = psScript
458 Case UCase(
"OnFocusLost
")
459 sPrevious = ._OnFocusLost
460 ._OnFocusLost = psScript
461 Case UCase(
"OnItemStateChanged
")
462 sPrevious = ._OnItemStateChanged
463 ._OnItemStateChanged = psScript
464 Case UCase(
"OnKeyPressed
")
465 sPrevious = ._OnKeyPressed
466 ._OnKeyPressed = psScript
467 Case UCase(
"OnKeyReleased
")
468 sPrevious = ._OnKeyReleased
469 ._OnKeyReleased = psScript
470 Case UCase(
"OnMouseDragged
")
471 sPrevious = ._OnMouseDragged
472 ._OnMouseDragged = psScript
473 Case UCase(
"OnMouseEntered
")
474 sPrevious = ._OnMouseEntered
475 ._OnMouseEntered = psScript
476 Case UCase(
"OnMouseExited
")
477 sPrevious = ._OnMouseExited
478 ._OnMouseExited = psScript
479 Case UCase(
"OnMouseMoved
")
480 sPrevious = ._OnMouseMoved
481 ._OnMouseMoved = psScript
482 Case UCase(
"OnMousePressed
")
483 sPrevious = ._OnMousePressed
484 ._OnMousePressed = psScript
485 Case UCase(
"OnMouseReleased
")
486 sPrevious = ._OnMouseReleased
487 ._OnMouseReleased = psScript
488 Case UCase(
"OnTextChanged
")
489 sPrevious = ._OnTextChanged
490 ._OnTextChanged = psScript
492 ' Compare previous and new event to know what to do next with the listener
493 If sPrevious = psScript Then GoTo Finally
' No change
494 If Len(sPrevious) =
0 Then
' New event
495 iCounterIncrement = +
1
496 ElseIf Len(psScript) =
0 Then
' Cancel event
497 iCounterIncrement = -
1
498 Else
' Event replacement
499 iCounterIncrement =
0
502 ' Setup a new fresh listener, only once by listener during dialog or control life time,
503 ' (re)add it to the instance view or remove the existing one if not needed anymore
504 Select Case sListener
505 Case
"XActionListener
"
506 ._ActionCounter = ._ActionCounter + iCounterIncrement
507 If ._ActionCounter =
1 Then
508 If IsNull(._ActionListener) Then Set ._ActionListener = CreateUnoListener(
"_SFACTION_
", cstPrefix
& sListener)
509 If iCounterIncrement =
1 Then oView.addActionListener(._ActionListener)
510 ElseIf ._ActionCounter
<=
0 Then
511 If Not IsNull(._ActionListener) Then oView.removeActionListener(._ActionListener)
512 ._ActionCounter =
0 ' Prevent negative values
514 Case
"XAdjustmentListener
"
515 ._AdjustmentCounter = ._AdjustmentCounter + iCounterIncrement
516 If ._AdjustmentCounter =
1 Then
517 If IsNull(._AdjustmentListener) Then Set ._AdjustmentListener = CreateUnoListener(
"_SFADJUST_
", cstPrefix
& sListener)
518 If iCounterIncrement =
1 Then oView.addAdjustmentListener(._AdjustmentListener)
519 ElseIf ._AdjustmentCounter
<=
0 Then
520 If Not IsNull(._AdjustmentListener) Then oView.removeAdjustmentListener(._AdjustmentListener)
521 ._AdjustmentCounter =
0 ' Prevent negative values
523 Case
"XFocusListener
"
524 ._FocusCounter = ._FocusCounter + iCounterIncrement
525 If ._FocusCounter =
1 Then
526 If IsNull(._FocusListener) Then Set ._FocusListener = CreateUnoListener(
"_SFFOCUS_
", cstPrefix
& sListener)
527 If iCounterIncrement =
1 Then oView.addFocusListener(._FocusListener)
528 ElseIf ._FocusCounter
<=
0 Then
529 If Not IsNull(._FocusListener) Then oView.removeFocusListener(._FocusListener)
530 ._FocusCounter =
0 ' Prevent negative values
532 Case
"XItemListener
"
533 ._ItemCounter = ._ItemCounter + iCounterIncrement
534 If ._ItemCounter =
1 Then
535 If IsNull(._ItemListener) Then Set ._ItemListener = CreateUnoListener(
"_SFITEM_
", cstPrefix
& sListener)
536 If iCounterIncrement =
1 Then oView.addItemListener(._ItemListener)
537 ElseIf ._ItemCounter
<=
0 Then
538 If Not IsNull(._ItemListener) Then oView.removeItemListener(._ItemListener)
539 ._ItemCounter =
0 ' Prevent negative values
541 Case
"XKeyListener
"
542 ._KeyCounter = ._KeyCounter + iCounterIncrement
543 If ._KeyCounter=
1 Then
544 If IsNull(._KeyListener) Then Set ._KeyListener = CreateUnoListener(
"_SFKEY_
", cstPrefix
& sListener)
545 If iCounterIncrement =
1 Then oView.addKeyListener(._KeyListener)
546 ElseIf ._KeyCounter
<=
0 Then
547 If Not IsNull(._KeyListener) Then oView.removeKeyListener(._KeyListener)
548 ._KeyCounter =
0 ' Prevent negative values
550 Case
"XMouseListener
"
551 ._MouseCounter = ._MouseCounter + iCounterIncrement
552 If ._MouseCounter=
1 Then
553 If IsNull(._MouseListener) Then Set ._MouseListener = CreateUnoListener(
"_SFMOUSE_
", cstPrefix
& sListener)
554 If iCounterIncrement =
1 Then oView.addMouseListener(._MouseListener)
555 ElseIf ._MouseCounter
<=
0 Then
556 If Not IsNull(._MouseListener) Then oView.removeMouseListener(._MouseListener)
557 ._MouseCounter =
0 ' Prevent negative values
559 Case
"XMouseMotionListener
"
560 ._MouseMotionCounter = ._MouseMotionCounter + iCounterIncrement
561 If ._MouseMotionCounter =
1 Then
562 If IsNull(._MouseMotionListener) Then Set ._MouseMotionListener = CreateUnoListener(
"_SFMOVE_
", cstPrefix
& sListener)
563 If iCounterIncrement =
1 Then oView.addMouseMotionListener(._MouseMotionListener)
564 ElseIf ._MouseMotionCounter
<=
0 Then
565 If Not IsNull(._MouseMotionListener) Then oView.removeMouseMotionListener(._MouseMotionListener)
566 ._MouseMotionCounter =
0 ' Prevent negative values
568 Case
"XTextListener
"
569 ._TextCounter = ._TextCounter + iCounterIncrement
570 If ._TextCounter =
1 Then
571 If IsNull(._TextListener) Then Set ._TextListener = CreateUnoListener(
"_SFTEXT_
", cstPrefix
& sListener)
572 If iCounterIncrement =
1 Then oView.addTextListener(._TextListener)
573 ElseIf ._TextCounter
<=
0 Then
574 If Not IsNull(._TextListener) Then oView.removeTextListener(._TextListener)
575 ._TextCounter =
0 ' Prevent negative values
582 _SetOnProperty = bSet
587 End Function
' SFDialogs.SF_Dialoglistener._SetOnProperty
589 REM -----------------------------------------------------------------------------
590 Public Sub _TriggerEvent(ByVal EventType, Optional ByRef poEvent As Object)
591 ''' Triggered by the EventType event in a dialog or dialog control
592 ''' The argument is passed to a user routine stored in the SF_Dialog or SF_DialogControl instance
593 ''' as a scripting framework URI
595 Dim oDialog As Object
' The SF_Dialog or SF_DialogControl object having triggered the event
596 Dim sScript As String
' Script to be invoked
598 On Local Error GoTo Catch
' Avoid stopping event scripts
601 If IsNull(poEvent) Or IsMissing(poEvent) Then Exit Sub
604 Set oDialog = ScriptForge.SF_Services.CreateScriptService(
"SFDialogs.DialogEvent
", poEvent)
605 If IsNull(oDialog) Then Exit Sub
607 Select Case EventType
608 Case
"actionPerformed
" : sScript = .OnActionPerformed
609 Case
"adjustmentValueChanged
" : sScript = .OnAdjustmentValueChanged
610 Case
"focusGained
" : sScript = .OnFocusGained
611 Case
"focusLost
" : sScript = .OnFocusLost
612 Case
"itemStateChanged
" : sScript = .OnItemStateChanged
613 Case
"mouseDragged
" : sScript = .OnMouseDragged
614 Case
"mouseEntered
" : sScript = .OnMouseEntered
615 Case
"mouseExited
" : sScript = .OnMouseExited
616 Case
"mouseMoved
" : sScript = .OnMouseMoved
617 Case
"mousePressed
" : sScript = .OnMousePressed
618 Case
"mouseReleased
" : sScript = .OnMouseReleased
619 Case
"textChanged
" : sScript = .OnTextChanged
620 Case Else : sScript =
"" ' Should not happen
622 If Len(sScript) =
0 Then Exit Sub
623 ScriptForge.SF_Session._ExecuteScript(sScript, poEvent)
630 End Sub
' SFDialogs.SF_Dialoglistener._TriggerEvent
632 REM ============================================ END OF SFDIALOGS.SF_DIALOGLISTENER