Compartilhar via


System.Gadget.Settings.ClosingEvent.cancel property

[The Windows Gadget Platform/Sidebar is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions. ]

Gets or sets whether to cancel the onSettingsClosing event.

This property is read/write.

Syntax

bcancel = System.Gadget.Settings.ClosingEvent.cancel
System.Gadget.Settings.ClosingEvent.cancel = bcancel

Property value

A Boolean that specifies or receives whether to cancel the event.

(false)

Default. Event is not canceled.

(true)

Default. Event is canceled.

Remarks

Useful for situations where a Settings form requires particular fields to be modified before the user can click Ok. This ensures the Settings dialog can stay open until all required information is entered.

Examples

The following example demonstrates how to ensure the Settings dialog closes when desired.

// Delegate for the settings closing event. 
System.Gadget.onSettingsClosing = SettingsClosing;
        
// --------------------------------------------------------------------
// Handle the Settings dialog closing event.
// Parameters:
// event - System.Gadget.Settings.ClosingEvent argument.
// --------------------------------------------------------------------
function SettingsClosing(event)
{
    // User hit OK on the settings page.
    if (event.closeAction == event.Action.commit)
    {
        if (txtUserEntry.value != "")
        {        
            System.Gadget.Settings.writeString(
                "settingsUserEntry", txtUserEntry.value);
            // Allow the Settings dialog to close.
            event.cancel = false;
        }
        // No user entry, cancel the Settings closing event.
        else
        {
            event.cancel = true;  
        }
    }
}

Requirements

Minimum supported client
Windows Vista [desktop apps only]
Minimum supported server
Windows Server 2008 [desktop apps only]
End of client support
Windows 7
End of server support
Windows Server 2008
IDL
Sidebar.idl
DLL
Sidebar.Exe (version 1.00 or later)