GP SoftwareTwitter
Opus FAQsManualCommandsObjects

DO11 Scripting: Create Lister variables on OnClick function


Is there some way to access to an object type Lister (especifically the current active Lister) from a OnClick function?
I ask because as I read the scripting info, the only way is via DOpus.Listers, althought you retrieve all the Listers, and there’s no way to know who Lister is the current active(the one where OnCLick() applies), so there’s no way to create Lister variables.
Ex. I want to do a hotkey/button that open/close the viewpane, with some modifications:
If the Viewpane is off, then:
first set a boolean variable (VIEWPANEDUAL) based on if dual is on or off.
If dual is on, turn it off, and then set a boolean variable (VIEWPANESWAP) based of if source is on left or right.
After that, turn on the viewpane.
If the VIewpane is on, then:
Close the viewpane.
if VIEWPANEDUAL is true, turn dual on
if VIEWPANEDUAL and VIEWPANESWAP are true, do a swap.
In Dopus 10, I achieve this with an Autohotkey Script, however in DO11 I decide to do it via a script, but there’s no way to create/set Lister variables, since you (supposed you have 2 Listers with the same tabs,toolbars, selected items,etc) can’t get the current Lister object.
Any help?. Here are the code:

@language vbscript

Function OnClick(ByRef ClickData)
'I don’t understand why this should be swapped,
If (ClickData.Func.Command.IsSet(“VIEWPANE=Off”)) Then
’if this says True, means that is on :?
DOpus.OutputString(“VIEWPANE is on”)
Call Restore(ClickData)
DOpus.OutputString(“VIEWPANE is off”)
Call Save(ClickData)
End If
End Function

Sub Restore(ClickData)
Dim dual, swap
dual = false
swap = false
ClickData.Func.Command.RunCommand(“Set VIEWPANE=Off”)
If DOpus.vars.Exists(“VIEWPANEDUAL”) Then
dual = DOpus.vars.Get(“VIEWPANEDUAL”)
DOpus.OutputString(“no dual”)
End If
’If the variable VIEWPANEDUAL is false, means that before open the viewpane,
'dual was off.
'We have to ask if currently dual is off, in case that was open it by the user after the viewpane
If (ClickData.Func.Command.IsSet(“DUAL=Off”)) and dual Then
ClickData.Func.Command.RunCommand(“SET Dual=Remember,Toggle”)
If DOpus.vars.Exists(“VIEWPANESWAP”) Then
swap = DOpus.vars.Get(“VIEWPANESWAP”)
DOpus.OutputString(“no swap”)
End If
If swap Then
ClickData.Func.Command.RunCommand(“Go SWAP”)
End If
End If
End Sub

Sub Save(ClickData)
'If dual is on means that we have to close dual first (but with remember option)
If (ClickData.Func.Command.IsSet(“DUAL=Off”)) Then
DOpus.OutputString(“dual is off”)
DOpus.vars.Set “VIEWPANEDUAL”, false
DOpus.OutputString(“dual is on”)
DOpus.vars.Set “VIEWPANEDUAL”, true
’If the source tab is in the right, means we have to swap it after close the viewpane
If ClickData.Func.sourcetab.right Then
DOpus.vars.Set “VIEWPANESWAP”, true
DOpus.vars.Set “VIEWPANESWAP”, false
End If
ClickData.Func.Command.RunCommand(“SET Dual=Remember,Toggle”)
End If
ClickData.Func.Command.RunCommand(“Set VIEWPANE=On”)
End Sub[/code]
Perhaps if on a OnClick() function, you can access to a Lister object the same way as it is with the DOpus object?

Enhance set DUAL=On,remember

If you grab Beta 4, you can now get the Lister from the Tab, e.g.

Function OnClick(ByRef ClickData) Set Tab = ClickData.Func.Command.SourceTab Set Lister = Tab.Lister ' ... End Function