Solution total command way delete

Want to provide a public solution how to delete files and folders in total commander style. Means F8 deletes marked or focused files:

Add a new shortcut

2018-12-31%2014_30_56-Command%20Editor%20-%20Directory%20Opus

And use this script:

function OnClick(clickData)
{
	// Requires Opus 12.11 or above.
	var cmd = clickData.func.command;

	var tab = clickData.func.sourcetab;
	var focusItem = tab.GetFocusItem();

	var selectedItems = tab.selected; 

	if (tab.selstats.selfiles > 0 || tab.selstats.seldirs > 0){
		cmd.setFiles( selectedItems );
		
	}else{
	 
		if (focusItem != null) {
			cmd.ClearFiles();
			cmd.AddFile(focusItem);
		}
	}
	
	cmd.RunCommand("delete");
	
}

For secure wipe (shift+F8) just use the command "delete secure".

Those will already be selected into the command object (when you get it via clickdata) so you don't need to do that part.

tab.selected.count is a quick way to check is anything is selected.