I have created a toolbar menu with a couple of filters to hide files and folders not matching the filter. I would now like to change the background when one of these filters are implemented (the same way the folder background color can change when using the quickfilter).
Can somebody please provide me with a script to:
Call a command to change the background color when I implement one of my filters
Restore the original background color when I change folders or cancel the filter.
I think changing the background can only be done from a script by loading a folder format, which would change more than just the background.
Instead, you could make your filters set the quickfilter (instead of whichever folder they are currently using), and the automatic background colour change can then be used.
[quote="leo"]I think changing the background can only be done from a script by loading a folder format, which would change more than just the background.
Instead, you could make your filters set the quickfilter (instead of whichever folder they are currently using), and the automatic background colour change can then be used.[/quote]
I tried the quickfilter, but how do I filter out files that does not match a certain date. This is one of my filters
my consolation prize would then be the following...
As I do not have gridlines displayed, I can turn it on whenever one of my filters is implemented, but I do not know how to turn it off with a addin script.
I tried this but the script does not show up in toolbar scripts:
[code]option explicit
' NoGrid
'
'
' This is a script for Directory Opus.
' See Buttons/Scripts - Directory Opus Resource Centre for development information.
'
'
'
' Called by Directory Opus to initialize the script
Function OnInit(initData)
initData.name = "NoGrid"
initData.desc = ""
initData.copyright = ""
initData.version = "1.0"
initData.default_enable = false
End Function
' Called after a new folder is read in a tab
Function OnAfterFolderChange(afterFolderChangeData)
Set GRIDLINES off
End Function[/code]
Okay, I now have a script that does show up under Toolbars -> Scripts. It is ticked to be active but the gridlines do not go away.
What am I doing wrong?
[code]option explicit
' NoGrid
'
'
' This is a script for Directory Opus.
' See http://www.gpsoft.com.au/DScripts/redirect.asp?page=scripts for development information.
'
'
'
' Called by Directory Opus to initialize the script
Function OnInit(initData)
initData.name = "NoGrid"
initData.desc = ""
initData.copyright = ""
initData.version = "1.0"
initData.default_enable = True
End Function
' Called after a new folder is read in a tab
Function OnAfterFolderChange(afterFolderChangeData)
Call NoGrid
End Function
Sub NoGrid()
Set objCmd = DOpus.CreateCommand
objCmd.RunCommand("Set GRIDLINES off")
Set objCmd = Nothing
End Sub[/code]
It's probably because your command does not reach the correct tab. Try this, it sets the source tab on the command object, before running you command.
Not tested to work, but should.
[code]Option Explicit
Function OnInit(initData)
initData.name = "NoGrid"
initData.desc = ""
initData.copyright = ""
initData.version = "1.0"
initData.default_enable = True
End Function
Function OnAfterFolderChange(afterFolderChangeData)
NoGrid(afterFolderChangeData.tab)
End Function
Function NoGrid( tab )
Set objCmd = DOpus.CreateCommand
objCmd.SetSourceTab(tab)
objCmd.RunCommand("Set GRIDLINES off")
Set objCmd = Nothing
End Function
[/code]
[quote="tbone"]It's probably because your command does not reach the correct tab. Try this, it sets the source tab on the command object, before running you command.
Not tested to work, but should.
[code]Option Explicit
Function OnInit(initData)
initData.name = "NoGrid"
initData.desc = ""
initData.copyright = ""
initData.version = "1.0"
initData.default_enable = True
End Function
Function OnAfterFolderChange(afterFolderChangeData)
NoGrid(afterFolderChangeData.tab)
End Function
Function NoGrid( tab )
Set objCmd = DOpus.CreateCommand
objCmd.SetSourceTab(tab)
objCmd.RunCommand("Set GRIDLINES off")
Set objCmd = Nothing
End Function
[/code][/quote]
Thanks for the help tbone. Unfortunately it still does not turn it off. Any other ideas?
There was a dim objCmd missing in your NoGrid() function (needed if you make use of option explicit), now it should work. Whenever you write these scripts, take an eye or better two on the script console of dopus, it tells you if the script fails, what was the case here.
[code]Option Explicit
Function OnInit(initData)
initData.name = "Event.GUI: GridLinesOff"
initData.desc = ""
initData.copyright = ""
initData.version = "1.0"
initData.default_enable = True
End Function
Function OnAfterFolderChange(afterFolderChangeData)
NoGrid(afterFolderChangeData.tab)
End Function
Function NoGrid( tab )
dim objCmd : Set objCmd = DOpus.NewCommand
objCmd.SetSourceTab(tab)
objCmd.RunCommand("Set GRIDLINES off")
Set objCmd = Nothing
End Function[/code]
Nice to hear, thanks for your feedback!
What I wanted to add: Another reason the script failed before, was because you used DOpus.CreateCommand instead of DOpus.NewCommand.
What mystic reference did you look up to find "CreateCommand"? o)