ScripForge (SF_Dialog) new OrderTabs() method
Set the tabulation index f a series of controls. The sequence of controls are given as an array of control names from the first to the last. Next controls will not be accessible (anymore ?) via the TAB key if >=1 of next conditions is met: - if they are not in the given list - if their type is FixedLine, GroupBox or ProgressBar - if the control is disabled Args: TabsList: an array of valid control names in the order of tabulation. Start: the tab index to be assigned to the 1st control in the list. Default = 1. Increment: the difference between 2 successive tab indexes. Default = 1. Returns: True when successful. The method is available from Basic and Python user scripts This change will require an update of the SF_Dialog help page. Change-Id: Ie854227691c4e182b49a521b1285deaa4de3d1ff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152166 Reviewed-by: Jean-Pierre Ledure <jp@ledure.be> Tested-by: Jenkins
This commit is contained in:
@@ -1977,6 +1977,9 @@ class SFDialogs:
|
||||
l10nobj = l10n.objectreference if isinstance(l10n, SFScriptForge.SF_L10N) else l10n
|
||||
return self.ExecMethod(self.vbMethod + self.flgObject, 'GetTextsFromL10N', l10nobj)
|
||||
|
||||
def OrderTabs(self, tabslist, start = 1, increment = 1):
|
||||
return self.ExecMethod(self.vbMethod, 'OrderTabs', tabslist, start, increment)
|
||||
|
||||
def Resize(self, left = -99999, top = -99999, width = -1, height = -1):
|
||||
return self.ExecMethod(self.vbMethod + self.flgHardCode, 'Resize', left, top, width, height)
|
||||
|
||||
|
@@ -2095,6 +2095,7 @@ Public Function Methods() As Variant
|
||||
, "EndExecute" _
|
||||
, "Execute" _
|
||||
, "GetTextsFromL10N" _
|
||||
, "OrderTabs" _
|
||||
, "Resize" _
|
||||
, "SetPageManager" _
|
||||
, "Terminate" _
|
||||
@@ -2102,6 +2103,90 @@ Public Function Methods() As Variant
|
||||
|
||||
End Function ' SFDialogs.SF_Dialog.Methods
|
||||
|
||||
REM -----------------------------------------------------------------------------
|
||||
Public Function OrderTabs(ByRef Optional TabsList As Variant _
|
||||
, ByVal Optional Start As Variant _
|
||||
, ByVal Optional Increment As Variant _
|
||||
) As Boolean
|
||||
''' Set the tabulation index f a series of controls.
|
||||
''' The sequence of controls are given as an array of control names from the first to the last.
|
||||
''' Next controls will not be accessible (anymore ?) via the TAB key if >=1 of next conditions is met:
|
||||
''' - if they are not in the given list
|
||||
''' - if their type is FixedLine, GroupBox or ProgressBar
|
||||
''' - if the control is disabled
|
||||
''' Args:
|
||||
''' TabsList: an array of valid control names in the order of tabulation
|
||||
''' Start: the tab index to be assigned to the 1st control in the list. Default = 1
|
||||
''' Increment: the difference between 2 successive tab indexes. Default = 1
|
||||
''' Returns:
|
||||
''' True when successful
|
||||
''' Example:
|
||||
''' dialog.OredrTabs(Array("myListBox", "myTextField", "myNumericField"), Start := 10)
|
||||
|
||||
Dim bOrder As Boolean ' Return value
|
||||
Dim vControlNames As Variant ' List of control names in the dialog
|
||||
Dim oControl As Object ' A SF_DialogControl instance
|
||||
Dim bValid As Boolean ' When True, the considered control deserves a tab stop
|
||||
Dim iTabIndex As Integer ' The tab index to be set
|
||||
Dim vWrongTypes As Variant ' List of rejected control types
|
||||
Dim i As Long
|
||||
|
||||
Const cstThisSub = "SFDialogs.Dialog.OrderTabs"
|
||||
Const cstSubArgs = "TabsList, [Start=1], Încrement=1]"
|
||||
|
||||
If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
|
||||
bOrder = False
|
||||
|
||||
Check:
|
||||
If IsMissing(Start) Or IsEmpty(Start) Then Start = 1
|
||||
If IsMissing(Increment) Or IsEmpty(Increment) Then Increment = 1
|
||||
If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
|
||||
If Not ScriptForge.SF_Utils._ValidateArray(TabsList, "TabsList", 1, V_STRING, True) Then GoTo Finally
|
||||
If Not SF_Utils._Validate(Start, "Start", ScriptForge.V_NUMERIC) Then GoTo Finally
|
||||
If Not SF_Utils._Validate(Increment, "Increment", ScriptForge.V_NUMERIC) Then GoTo Finally
|
||||
End If
|
||||
|
||||
Try:
|
||||
vWrongTypes = Array("FixedLine", "GroupBox", "ProgressBar")
|
||||
|
||||
' Remove all existing tabulations
|
||||
vControlNames = _DialogModel.getElementNames()
|
||||
For i = 0 To UBound(vControlNames)
|
||||
Set oControl = Controls(vControlNames(i))
|
||||
With oControl._ControlModel
|
||||
If Not ScriptForge.SF_Array.Contains(vWrongTypes, oControl._ControlType) Then
|
||||
.TabStop = False
|
||||
.TabIndex = -1
|
||||
End If
|
||||
End With
|
||||
Next i
|
||||
|
||||
iTabIndex = Start
|
||||
|
||||
' Go through the candidate controls for being tabulated and set tabs
|
||||
For i = LBound(TabsList) To UBound(TabsList)
|
||||
Set oControl = Controls(TabsList(i)) ' Error checking on input names happens here
|
||||
With oControl._ControlModel
|
||||
bValid = Not ScriptForge.SF_Array.Contains(vWrongTypes, oControl._ControlType)
|
||||
If bValid Then bValid = .Enabled
|
||||
If bValid Then
|
||||
.TabStop = True
|
||||
.TabIndex = iTabIndex
|
||||
iTabIndex = iTabIndex + Increment
|
||||
End If
|
||||
End With
|
||||
Next i
|
||||
|
||||
bOrder = True
|
||||
|
||||
Finally:
|
||||
OrderTabs = bOrder
|
||||
SF_Utils._ExitFunction(cstThisSub)
|
||||
Exit Function
|
||||
Catch:
|
||||
GoTo Finally
|
||||
End Function ' SFDialogs.SF_Dialog.OrderTabls
|
||||
|
||||
REM -----------------------------------------------------------------------------
|
||||
Public Function Properties() As Variant
|
||||
''' Return the list or properties of the Dialog class as an array
|
||||
@@ -2971,4 +3056,4 @@ Private Function _Repr() As String
|
||||
End Function ' SFDialogs.SF_Dialog._Repr
|
||||
|
||||
REM ============================================ END OF SFDIALOGS.SF_DIALOG
|
||||
</script:module>
|
||||
</script:module>
|
@@ -1960,7 +1960,7 @@ Const cstSubArgs = ""
|
||||
, CTLFORMATTEDFIELD, CTLHYPERLINK, CTLIMAGECONTROL, CTLLISTBOX, CTLNUMERICFIELD, CTLPATTERNFIELD _
|
||||
, CTLRADIOBUTTON, CTLSCROLLBAR, CTLTABLECONTROL, CTLTEXTFIELD, CTLTIMEFIELD, CTLTREECONTROL
|
||||
If oSession.HasUnoProperty(_ControlModel, "TabIndex") Then
|
||||
If CBool(_ControlModel.TabStop) Or IsEmpty(_ControlModel.TabStop) Then _PropertyGet = _ControlModel.TabIndex Else _PropertyGet = 0
|
||||
If CBool(_ControlModel.TabStop) Or IsEmpty(_ControlModel.TabStop) Then _PropertyGet = _ControlModel.TabIndex Else _PropertyGet = -1
|
||||
End If
|
||||
Case Else : GoTo CatchType
|
||||
End Select
|
||||
@@ -2489,7 +2489,6 @@ Const cstSubArgs = "Value"
|
||||
Case Else
|
||||
bSet = False
|
||||
End Select
|
||||
|
||||
Finally:
|
||||
_PropertySet = bSet
|
||||
ScriptForge.SF_Utils._ExitFunction(cstThisSub)
|
||||
|
@@ -426,7 +426,7 @@ Try:
|
||||
End With
|
||||
|
||||
' Create the view and associate model and view
|
||||
Set oView = oprocessManager.createInstance(cstDialogView)
|
||||
Set oView = oProcessManager.createInstance(cstDialogView)
|
||||
oView.setModel(oModel)
|
||||
|
||||
' Initialize the basic SF_Dialog instance to return to the user script
|
||||
|
Reference in New Issue
Block a user