GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Confirm before closing lister window

Overview

This simple script adds a confirmation dialog when you click the lister window's close button, allowing you to confirm or cancel the closure.

image

You can hold a qualifier key (shift, alt, ctrl) while clicking the close button to suppress the confirmation.

If Windows or Opus are being shutdown entirely, the confirmation will not appear, so that it does not delay shutting down the machine.

Install

  • Download CloseConfirm.js.txt (948 Bytes)
  • Go to Preferences / Toolbars / Scripts.
  • Drag the script into the list and click OK.

History

v1.0 (09/Feb/2020)

  • Initial version.

Script Code

The download above is reproduced below, to help people browsing for scripting techniques:

function OnInit(initData)
{
	initData.name = "CloseConfirm";
	initData.version = "1.0";
	initData.copyright = "(c) 2020 Leo Davidson";
	initData.url = "https://resource.dopus.com/t/confirm-before-closing-lister-window/34600";
	initData.desc = "";
	initData.default_enable = true;
	initData.min_version = "12.0";
}

function OnCloseLister(closeListerData)
{
	// Is Opus, or Windows, being shutdown completely?
	if (closeListerData.shutdown)
	{
		return false; // Don't block closing the window.
	}

	// Are any qualifier keys held down?
	if (closeListerData.qualifiers != "none")
	{
		return false; // Don't block closing the window.
	}
	
	var dlg = closeListerData.lister.Dlg();
	
	var choice = dlg.Request("Are you sure you want to close the window?", "Close|Cancel", "Close Lister");
	
	if (choice == 1)
	{
		return false; // Don't block closing the window.
	}

	return true; // Block closing the window.
}
3 Likes

Awesome! Thanks! Somitimes i misclick, so this solves that :smiley:

1 Like