I was under the (seemingly false) impression that a button being enabled/disabled depended on files being/not being selected comes from the type of the code for passing filename used, that is, if I use the "need" form, it disables the button if there are no files selected and if I use the "need"-less form, the button is enabled, regardless of the files being selected or not.
I have taken the liberty to quote the relevant parts from the help in bold. This is the description for {filepath$} (the "need" form):
The "need" form of {filepath} (requires at least one selected item in the file list).
Full paths, one at a time, selected items required, long filenames, source file display
The description for {filepath} is the following:
Passes the full path and filename of each selected item. Files are passed one at a time - a command that uses this code will be repeated once for each additional selected item. If no files are selected the command will still be run, passing an empty string for this code.
Full paths, one at a time, selected items not required, long filenames, source file display
(The second quote above is actually not true for buttons. If there are no files selected, the button is disabled, and you cannot run the selected code, as the button won't be clickable. I guess it also depends on the actual command itself, some might not disable the button when there are no files selected).
The descriptions for the destination-side codes are kinda analog, so I thought these would work there as well, namely, if I use a destination-side code, it would disable the button if there are no files selected in the destination display, and if there were both type (side) of codes used, it would require files to be selected on both sides to make the button active.
Unfortunately, these do not work as I expected.
The code @lxp provided uses the function OnClick, which (I guess from the name) only runs when clicked, so it probably can not affect the button's enabled state. Is there an applicable function that I could use to toggle the button state depending on files being selected on both sides?