Filter fields swap

I have two filter fields on my toolbar which work on a per-tab basis and look like this:

What I need is to be able to quickly swap (or invert) them with a press of a toolbar button. I use them to monitor which filter is set via preset buttons using Set SHOWFILTERFILENAME and not so much for typing in them, but I do type occasionally.

  • One is designated with: files,hide
  • The other with: files,show

I know this method of filtering is deprecated but I use it in conjunction with fayt to additionally narrow down my filters.
I looked into the new DOpus.filters property but it returns the global filters and not the tab-specific ones.
Global filtering hides stuff like thumbs.db etc and should not be touched as it would affect all tabs in all listers.
I also couldn't find any filter property in ClickData.func.sourcetab's tab.

Seeing the DOpus.filters addition I was hoping this could be implemented as well.

There was a related post but that is for an older Opus version from a long time ago:

Those fields change the folder format's hide/show options, which scripts can get via the Format object.

This worked great. Thank you Leo :grin:
Here's my final button code so people don't need to reinvent the wheel.

(paste to toolbar)

<?xml version="1.0"?>
<button backcol="none" display="icon" textcol="none">
	<label>Swap Filter</label>
	<icon1>#reload</icon1>
	<function type="script">
		<instruction>@script JScript</instruction>
		<instruction>function OnClick(clickData)</instruction>
		<instruction>{</instruction>
		<instruction>	var command = DOpus.NewCommand;</instruction>
		<instruction>	var format = clickData.func.sourcetab.format;</instruction>
		<instruction />
		<instruction>	if(format.hide_files.length &gt; 0) {</instruction>
		<instruction>		command.RunCommand(&quot;Set CLEARFILTERS&quot;);</instruction>
		<instruction>		command.RunCommand(&quot;Set SHOWFILTERFILENAME=&quot; + format.hide_files);</instruction>
		<instruction>		format.Update();</instruction>
		<instruction>	} else if(format.show_files.length &gt; 0) {</instruction>
		<instruction>		command.RunCommand(&quot;Set CLEARFILTERS&quot;);</instruction>
		<instruction>		command.RunCommand(&quot;Set HIDEFILTERFILENAME=&quot; + format.show_files);</instruction>
		<instruction>		format.Update();</instruction>
		<instruction>	}</instruction>
		<instruction>}</instruction>
	</function>
</button>
1 Like