ScriptForge Don't watch close button of stored dialogs
Dialogs can either be stored in a library or created from scratch. When run in non-modal mode, the closing of a stored dialog with the Close top-right cross is done by LO correctly. When the dialog is created from scratch, a coded XTopWindowListener should do the job. So far, the listener was activated for all dialogs. Additionally the Console is a stored dialog. When closed and relaunched, the processing will now handle the window Close and the built-in Close buttons identically, at least apparently. Change-Id: I29e0881989816fbf7e3e8bd12f59517bde4b3047 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184662 Reviewed-by: Jean-Pierre Ledure <jp@ledure.be> Tested-by: Jean-Pierre Ledure <jp@ledure.be> Tested-by: Jenkins
This commit is contained in:
@@ -364,28 +364,25 @@ Try:
|
||||
With _SF_
|
||||
bConsoleActive = False
|
||||
If Not IsNull(.ConsoleDialog) Then bConsoleActive = .ConsoleDialog._IsStillAlive(False) ' False to not raise an error
|
||||
If bConsoleActive And Modal = False Then
|
||||
' Bring to front
|
||||
.ConsoleDialog.Activate()
|
||||
Else
|
||||
' Initialize dialog and fill with actual data
|
||||
' The dual modes (modal and non-modal) require to have 2 close buttons o/w only 1 is visible
|
||||
' - a usual OK button
|
||||
' - a Default button triggering the Close action
|
||||
Set .ConsoleDialog = CreateScriptService("SFDialogs.Dialog", "GlobalScope", "ScriptForge", "dlgConsole", _Context)
|
||||
' Setup labels and visibility
|
||||
Set oModalBtn = .ConsoleDialog.Controls("CloseModalButton")
|
||||
Set oNonModalBtn = .ConsoleDialog.Controls("CloseNonModalButton")
|
||||
oModalBtn.Visible = Modal
|
||||
oNonModalBtn.Visible = CBool(Not Modal)
|
||||
' Load console lines
|
||||
_ConsoleRefresh()
|
||||
.ConsoleDialog.Execute(Modal)
|
||||
' Terminate the modal dialog
|
||||
If Modal Then
|
||||
Set .ConsoleControl = .ConsoleControl.Dispose()
|
||||
.ConsoleDialog.Terminate()
|
||||
End If
|
||||
If bConsoleActive And Modal = False Then _CloseConsole()
|
||||
|
||||
' Initialize dialog and fill with actual data
|
||||
' The dual modes (modal and non-modal) require to have 2 close buttons o/w only 1 is visible
|
||||
' - a usual OK button
|
||||
' - a Default button triggering the Close action
|
||||
Set .ConsoleDialog = CreateScriptService("SFDialogs.Dialog", "GlobalScope", "ScriptForge", "dlgConsole", _Context)
|
||||
' Setup labels and visibility
|
||||
Set oModalBtn = .ConsoleDialog.Controls("CloseModalButton")
|
||||
Set oNonModalBtn = .ConsoleDialog.Controls("CloseNonModalButton")
|
||||
oModalBtn.Visible = Modal
|
||||
oNonModalBtn.Visible = CBool(Not Modal)
|
||||
' Load console lines
|
||||
_ConsoleRefresh()
|
||||
.ConsoleDialog.Execute(Modal)
|
||||
' Terminate the modal dialog
|
||||
If Modal Then
|
||||
Set .ConsoleControl = .ConsoleControl.Dispose()
|
||||
.ConsoleDialog.Terminate()
|
||||
End If
|
||||
End With
|
||||
|
||||
@@ -1306,8 +1303,9 @@ Try:
|
||||
With _SF_
|
||||
If Not IsNull(.ConsoleDialog) Then
|
||||
If .ConsoleDialog._IsStillAlive(False) Then ' False to not raise an error
|
||||
Set .ConsoleControl = .ConsoleControl.Dispose()
|
||||
Set .ConsoleDialog = .ConsoleDialog.Dispose()
|
||||
.ConsoleDialog.Terminate()
|
||||
Set .ConsoleControl = Nothing
|
||||
Set .ConsoleDialog = Nothing
|
||||
End If
|
||||
End If
|
||||
End With
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
|
||||
<library:library xmlns:library="http://openoffice.org/2000/library" library:name="ScriptForge" library:readonly="false" library:passwordprotected="false">
|
||||
<library:element library:name="SF_Exception"/>
|
||||
<library:element library:name="SF_Dictionary"/>
|
||||
<library:element library:name="SF_Session"/>
|
||||
<library:element library:name="SF_Timer"/>
|
||||
<library:element library:name="SF_FileSystem"/>
|
||||
<library:element library:name="SF_Root"/>
|
||||
<library:element library:name="__License"/>
|
||||
<library:element library:name="SF_Utils"/>
|
||||
<library:element library:name="_ModuleModel"/>
|
||||
<library:element library:name="_CodingConventions"/>
|
||||
<library:element library:name="SF_Services"/>
|
||||
<library:element library:name="SF_UI"/>
|
||||
<library:element library:name="SF_Exception"/>
|
||||
<library:element library:name="SF_Dictionary"/>
|
||||
<library:element library:name="SF_TextStream"/>
|
||||
<library:element library:name="SF_Array"/>
|
||||
<library:element library:name="SF_Region"/>
|
||||
@@ -12,12 +20,4 @@
|
||||
<library:element library:name="SF_PythonHelper"/>
|
||||
<library:element library:name="SF_Platform"/>
|
||||
<library:element library:name="SF_String"/>
|
||||
<library:element library:name="SF_Session"/>
|
||||
<library:element library:name="_ModuleModel"/>
|
||||
<library:element library:name="_CodingConventions"/>
|
||||
<library:element library:name="SF_Utils"/>
|
||||
<library:element library:name="__License"/>
|
||||
<library:element library:name="SF_Root"/>
|
||||
<library:element library:name="SF_Timer"/>
|
||||
<library:element library:name="SF_FileSystem"/>
|
||||
</library:library>
|
||||
@@ -143,7 +143,9 @@ Private _MouseCounter As Integer ' Counts the number of events set on the
|
||||
Private _MouseMotionListener As Object ' com.sun.star.awt.XMouseMotionListener
|
||||
Private _OnMouseDragged As String ' Script to invoke when mouse is dragged from the dialog
|
||||
Private _OnMouseMoved As String ' Script to invoke when mouse is moved across the dialog
|
||||
Private _MouseMotionCounter As Integer ' Counts the number of events set on the listener
|
||||
Private _MouseMotionCounter As Integer ' Counts the number of events set on the listener
|
||||
' ---
|
||||
Private _TopWindowListener As Object ' com.sun.star.awt.XTopWindowListener
|
||||
|
||||
' Persistent storage for controls
|
||||
Private _ControlCache As Variant ' Array of control objects sorted like ElementNames of the Dialog model
|
||||
@@ -2050,7 +2052,6 @@ Public Function Execute(Optional ByVal Modal As Variant) As Long
|
||||
''' Select Case lReturn
|
||||
|
||||
Dim lExecute As Long ' Return value
|
||||
Dim oListener As Object ' com.sun.star.awt.XTopWindowListener
|
||||
Const cstThisSub = "SFDialogs.Dialog.Execute"
|
||||
Const cstSubArgs = "[Modal=True]"
|
||||
|
||||
@@ -2083,10 +2084,12 @@ Try:
|
||||
' To make visible an on-the-fly designed dialog when macro triggered from Python
|
||||
_DialogModel.DesktopAsParent = Not ( _BuiltFromScratch And _BuiltInPython )
|
||||
_DialogControl.setVisible(True)
|
||||
' Watch the window Close button
|
||||
Set oListener = CreateUnoListener("SFDialogs.SF_DialogListener._SFNONMODAL_" _
|
||||
, "com.sun.star.awt.XTopWindowListener")
|
||||
_DialogControl.addTopWindowListener(oListener)
|
||||
' Watch the window Close button - not to be done for stored dialogs
|
||||
If _BuiltFromScratch Then
|
||||
Set _TopWindowListener = CreateUnoListener("SFDialogs.SF_DialogListener._SFNONMODAL_" _
|
||||
, "com.sun.star.awt.XTopWindowListener")
|
||||
_DialogControl.addTopWindowListener(_TopWindowListener)
|
||||
End If
|
||||
lExecute = 0
|
||||
End If
|
||||
|
||||
@@ -3329,6 +3332,9 @@ Try:
|
||||
Set _MouseListener = Nothing
|
||||
Set _MouseMotionListener = Nothing
|
||||
|
||||
' Clean close listener for non-modal dialog
|
||||
If Not IsNull(_TopWindowListener) Then _DialogControl.removeTopWindowListener(_TopWindowListener)
|
||||
|
||||
Finally:
|
||||
Exit Sub
|
||||
End Sub ' SFDialogs.SF_Dialog._RemoveAllListeners
|
||||
|
||||
Reference in New Issue
Block a user