Clipboard.ContentChanged | contentchanged event

Applies to Windows only

Occurs when the data stored in the Clipboard changes.

Syntax


function onContentChanged(eventArgs) { /* Your code */ }
 
// addEventListener syntax
clipboard.addEventListener("contentchanged", onContentChanged);
clipboard.removeEventListener("contentchanged", onContentChanged);
 
- or -

clipboard.oncontentchanged = onContentChanged;


Event information

DelegateEventHandler [JavaScript] | System.EventHandler<Object> [.NET] | Windows.Foundation.EventHandler<Object> [C++]

Remarks

This event is helpful in situations when your app contains logic that varies depending on the contents on the clipboard. For example, your app might include a Paste button, which is disabled unless the Clipboard contains content.

Examples

The following example shows how to track changes to the Clipboard. The first code snippet registers a handler for the ContentChanged event. The second code snippet shows the event handler, which enables the app's paste command if the Clipboard contains a bitmap.


function RegisterEvents() {

    // Register a listener for the ContentChanged event. It is called whenever 
    // the clipboard content changes
    Windows.ApplicationModel.DataTransfer.Clipboard.addEventListener(
        "contentchanged", onClipboardContentChanged); 

// TODO: Register other event listeners here.

}



function onClipboardContentChanged(e) {
    var dataPackageView = Windows.ApplicationModel.DataTransfer.Clipboard.getContent();
    if (dataPackageView.contains(Windows.ApplicationModel.DataTransfer.StandardDataFormats.bitmap)) {
        // TODO: Enable the Paste command.

    }
}


Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

None supported

Namespace

Windows.ApplicationModel.DataTransfer
Windows::ApplicationModel::DataTransfer [C++]

Metadata

Windows.winmd

See also

Clipboard

 

 

Show:
© 2014 Microsoft