SFDialogs.Dialog service

The Dialog service contributes to the management of dialogs created with the Basic Dialog Editor. Each instance of the current class represents a single dialog box displayed to the user.

tip

A dialog box can be displayed in modal or in non-modal modes.


In modal mode, the box is displayed and the execution of the macro process is suspended until one of the OK or Cancel buttons is pressed. In the meantime, user actions executed on the box can trigger specific actions.

In non-modal mode, the dialog box is "floating" on the user desktop and the execution of the macro process continues normally. A non-modal dialog closes when it is terminated with the Terminate() method or when the LibreOffice session ends. The window close button is inactive in non-modal dialogs.

A dialog box disappears from memory after its explicit termination.

tip

The SFDialogs.Dialog service is closely related to the SFDialogs.DialogControl service.


Invocació i ús del servei

Abans d'utilitzar el servei Dialog, cal carregar o importar la biblioteca ScriptForge:

note

• Basic macros require to load ScriptForge library using the following statement:
GlobalScope.BasicLibraries.loadLibrary("ScriptForge")

• Python scripts require an import from scriptforge module:
from scriptforge import CreateScriptService


The Dialog service is invoked through the CreateScriptService method. It requires three positional arguments to specify the dialog box to activate:

Container: "GlobalScope" for preinstalled libraries or a window name as defined by ScriptForge.UI service. Empty string "" default value stands for the current document.

Library: The case-sensitive name of a library contained in the container. Default value is "Standard".

DialogName: A case-sensitive string designating the dialog.

Below LibreOffice Basic and Python examples are displaying the dlgConsole dialog that belongs to ScriptForge shared library:


      Dim oDlg As Object, lButton As Long
      Dim Container As String, Library As String, DialogName As String
      Set oDlg = CreateScriptService("SFDialogs.Dialog", "GlobalScope", "ScriptForge", "dlgConsole")
      '... la inicialització dels controls va aquí...
      lButton = oDlg.Execute()
      'Default mode = Modal
      If lButton = oDlg.OKBUTTON Then
      '... Process controls and do what is needed here
      End If
      oDlg.Terminate()
  

Or using Python:


    dlg = CreateScriptService('SFDialogs.Dialog', 'GlobalScope', 'ScriptForge', 'dlgConsole')
    #... la inicialització dels controls va aquí...
    rc = dlg.Execute()
    # Default mode is Modal
    if rc == dlg.OKBUTTON:
        # ... Process controls and do what is needed here
    dlg.Terminate()
  

Alternatively a Dialog instance can be retrieved via the SFDialogs.DialogEvent service, providing that the dialog was initiated with the Dialog service. DialogEvent returns the SFDialogs.Dialog service instance that triggered the event.


    Sub SomeEvent(ByRef poEvent As Object)
        Dim oDlg As Object
        Set oDlg = CreateScriptService("SFDialogs.DialogEvent", poEvent)
    End Sub
  

with Python:


    def some_event(event: uno):
        dlg = CreateScriptService("SFDialogs.DialogEvent", event)
  

Note that in previous examples, the prefix "SFDialogs." may be omitted when deemed appropriate.

Propietats

Nom

Només de lectura

Tipus

Descripció

OKBUTTON

Yes

Integer

Value = 1. An OK button was pressed.

CANCELBUTTON

Integer