Windows Dev Center

Collapse the table of content
Expand the table of content
Expand Minimize
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Clipboard.ContentChanged | contentchanged event

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 (Windows 10 device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

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

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

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:
© 2015 Microsoft