Modifier @disablenosel for both filetype and nothing selected

For a few days now, I'm trying to create a button which becomes disabled when:

  1. Nothing is selected.
  2. Files with the *.lnk extension are selected.

I've managed to partially make it work with @disablenosel:!type=*.lnk, so the button will be disabled if the *.lnk files are selected. The problem is that the button gets enabled when nothing is selected, and I want it to also be disabled when nothing is selected.

I've tried all kinds of combinations (including adding an extra @hidenosel as a hack, but it doesn't work in conjuction with @disablenosel -- is that by design?).

The krux of the problem is (as per docs) that the negation ! must be the first thing after the colon : (and it applies to the entire line), so something like @disablenosel:files,!type=*.lnk is not doable, neither is this syntax valid @disablenosel:!type=*.lnk,!files to flip the negation. Using multiple @disablenosel also doesn't work.

Try files,type=~(*.lnk)

Not sure if it'll cover all the cases, but I think something like that has worked for similar problems.

Thanks Leo, it works!

This syntax seems to enable more flexibility and presumably works everywhere throughout the Opus?

~ should work anywhere wildcards work, yeah.

Great! I hope the docs will be updated at some point :slight_smile:

~ has been in the docs for years. It's part of the wildcard syntax.

I primarily meant for the examples in the Command modifier reference, it didn't even occur to me to try the wildcard syntax for the @disablenosel because although the Standard wildcards are mentioned (and Pattern Matching Syntax is linked elsewhere for some other modifiers I wasn't interested in), the examples given for @disablenosel use their own syntax (! for negation) so I missed it.

They're two slightly different things.

  • You can invert the @disablenosel requirements with ! at the start.

    That includes things which are not wildcards. e.g. @disablenosel:!files means the button is only enabled when no files are selected:

    Nothing selected -> Enabled
    Folders (only) selected -> Enabled
    Files (only) selected -> Disabled
    Files & folders selected -> Disabled

    That's different to @disablenosel:dirs which is enabled if folders are selected:

    Nothing selected -> Disabled
    Folders (only) selected -> Enabled
    Files (only) selected -> Disabled
    Files & folders selected -> Enabled

  • You can invert wildcards with ~.

    That's just part of the wildcard syntax. It wouldn't make sense to re-list all of the wildcard syntax everywhere wildcards come up in the manual.

In some cases you can do the same thing using either method, of course.

1 Like

Thanks for the in-depth explanation!


For a feature-rich software such as Opus, getting help from the responsive developers on the forum is priceless (quite literally too) :smiley: