Fires on the target object before the selection is pasted from the system clipboard to the document.
If the event bubbles and is cancellable, return VARIANT_TRUE to prevent the event from bubbling to other event handlers in the document tree. Return VARIANT_FALSE to allow bubbling.
The DISPID for this event is defined in mshtmdid.h. Use this value to identify the event handler when implementing IDispatch::Invoke.
Bubbles Yes Cancels Yes To invoke After copying or cutting text:
- Right-click to display the shortcut menu and select Paste.
- Or press CTRL+V.
Default action None.
Creating custom code for pasting requires several steps:
- Set event.returnValue=false in the HTMLStyleElementEvents::onbeforepaste event to enable the Paste shortcut menu item.
- Cancel the default behavior of the client by including event.returnValue=false in the HTMLStyleElementEvents::onpaste event handler. This guideline applies only to objects, such as the text box, that have a defined default behavior.
- Specify a data format in which to paste the selection through the IHTMLDataTransfer::getData method of the clipboardData object.
- Invoke the IHTMLDataTransfer::getData method in the HTMLStyleElementEvents::onpaste event to execute custom code for pasting.