Named Filter Menu Version 2

FilterMenu Version 2

Latest Version (v2.2) : filtermenu.js.txt (39.1 KB)

Previous Versions : (17.1 KB)

This is a rewrite of the original 2018 FilterMenu GUI (Named Filter Menu):

Its main purpose is to provide a convenient way to access saved named filters combined with some useful companion Select options.

You can easily apply multiple filters in sequence, including ad-hoc simple or advanced filters, and you can choose to replace or add to existing selections.

The 2022 version responds to single left and right click on a named filter. It also includes "collection" options such as add, replace, duplicate, etc., as well as selection and hide/show options triggered via dialog buttons.

(1) The GUI tracks the current tab and the current path is shown near the top of the dialog.
(2) User defined filters are listed and can be left clicked to add to or replace current selections, or right clicked to remove matched items from current selections.
(3) Named filters and button actions operate on files, folders or both according the current Apply to..? setting. If qualifier keys are enabled, Ctrl, Alt, or Shift can be used to temporarily toggle the files/folders setting. Eligible buttons are flagged with blue borders.
(4) Buttons that act as toggles are flagged with yellow borders. When used with a qualifier key, ±Hide Files and ±Hide Folders toggles will prompt for a simple pattern to match; with no qualifer all files or folders are hidden or revealed.
(5) The target collection can be changed by overtyping the current name or by picking an existing collection from the drop down. ±Coll and ±Colls buttons are toggles that jump to the target collection (or coll://) and jump back. By default the same tab is reused. If qualifiers are active and a qualifier key is used then these buttons will jump to an existing tab or create a new tab if necessary.
(6) Preferences can be accessed quickly by clicking the Preferences button. If changes are made then the dialog needs to be restarted for the changes to be recognised.
(7) The Quit button can be used to exit the dialog and if the ESC option is active then the Esc key can also be used.
(8) When the showcommands option is enabled the information message will be replaced by the command that was executed by the most recent action.

How to install and use

Copy filtermenu.js.txt to /scripts (alias which points to the Script Addins folders) then..

Create a button on a toolbar that executes filtermenu
or type >filtermenu to execute as an "immediate" command.

Append options as required, e.g. filtermenu clearoutput collname="My Stuff"

Command line options are mostly the same as Preferences. fastclickms is a safety feature used to prevent multiple clicks of the same button being executed unless the second click occurs after the specified number of milliseconds has elapsed. The default value should not normally need to be adjusted. timerms is used internally to support single, rather than double, mouse click on a named filter. Again, the default value should not normally need to be adjusted.


Special thanks to @skinz who helped test and debug V2 and improve the GUI with constructive comments and suggestions, and to the ever helpful (and seldom sleeping) @leo whose Support for Prefs PAGE=FILTERS:MyFilter - #4 by Leo suggestion has been implemented when the Edit Filters button is clicked unqualified.


If you encounter any repeatable issues please run the command with the debug option - filtermenu debug - and share (or PM) the relevant debug trace.

Note that the clearoutput option switches debug mode on and pressing a qualifier key when starting filtermenu also switches debug mode on.


AWESOME work @aussieboykie!

Amazing, this script can even work very well in flat view mode with a very large number of files and folders... :+1:

Absolutely fantastic tool. Thank you!

Perfect tool, indeed! Thanks!

One question though: when starting the filtermenu and the popup is shown, it immediately opens the script log. The script's option "debug" is set to "false".

How can I stop the script from opening the log window on the bottom?

Totally Awesome !
Many thanks for this great script.

Is the clearoutput option set to true? It has the intentional side effect of setting debug on.

Both options are off


No matter if I set clearoutput to True or False, the log pops up and fills...

Are you opening the dialog via a hotkey? Try removing this line from the code:

if (!dbg) dbg = (ScriptCommandData.func.qualifiers!="none"); // Or use any qualifier key to force debug ON

No, as in the example above, I've created a toolbar button and added
filtermenu clearoutput collname="My Stuff"
as the command.

I've now commented those three lines below, but actually only the last one cause the log to disappear!

// if (!dbg) dbg = (Script.config.debug); // Or force debug ON via a script preference setting
// if (clearoutput) DOpus.Clearoutput();
// if (dbg) cmd.runcommand(Set UTILITY=OtherLog,On);

I found that this line enables the debug log, ignoring the script setting.
if (!dbg) dbg = (ScriptCommandData.func.qualifiers!="none");

According to the help

The string can contain any or all of the following: shift, ctrl, alt, lwin, rwin
If no qualifiers were down, the string will be: none

IMO, since I'm not pressing any key while clicking on the button, the code ScriptCommandData.func.qualifiers!="none" does not work as expected?

I've inserted a line for debugging purposes
DOpus.Output("qualifiers " + ScriptCommandData.func.qualifiers );
that correctly gives none in the log.

So why does the line
if (!dbg) dbg = (ScriptCommandData.func.qualifiers!="none");
set the variable dbg to true again?

Good catch @Leo. I added that undocumented feature mainly for my own convenience when testing. I might remove it in v2.1 (in a day or so) to avoid causing the issue that @Micky has experienced.

@Micky Starting with clearoutput as an option in the command line is the reason you are seeing what you do. Just remove that option and all should be well.

FWIW: no matter which string I use here xxxx for comparison and testing for equality
if (!dbg) dbg = (ScriptCommandData.func.qualifiers=="xxxx");
the dbg variable always gets set to true...

Unfortunately no, I did that already without modifying the script as Leo suggested, the log still fills up.

:raised_back_of_hand: I was wrong! Sorry. Removing the clearoutput option did solve it.

If you revert to the original v2.0 code and start with the command filtermenu with no options you should not see any debug trace unless you set debug or clearoutput options in Preferences.

1 Like

Still curious: why does this logical comparison not set the variable dbg correctly?
I would expect that if no qualifiers are available == "none", set dbg to false?

Are you sure it was that? If you had the clearoutput argument in your command then it would not have mattered.

Yes, I'm sure. To check, I just re-downloaded the version 2 script and added the clearoutput option/qualifier again and voila, the log window pops up again.

Removing the qualifier from the button's command line, however, still hides the log.

From a programmers perspective, I still do not get why this happens, especially when ScriptCommandData.func.qualifiers returns none, which should correctly set the dbg variable.

If dbg is already true then the rest of the command is not executed. If dbg is false then it will be set to true if a qualifier key is pressed.

Thus, if you execute filtermenu whilst pressing a qualifier key then debug mode will always be triggered. I find this technique convenient when developing code.

The head post has been updated to include v2.1 code. Changes from v2.0 are:

  • Most action buttons are disabled when the current tab is showing a special folder such as My PC.
  • Left and right click actions in the filters list are suppressed for special folders.
  • Version information is included in start/end debug trace messages.
  • Fixed a bug in command line parameters definition that would have caused some command line options to fail or be ignored.
  • The handling of ±Coll and ±Colls toggles has been improved.