Fires on the source element when the object or selection is removed from the document and added to the system clipboard.
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 selecting text:
- Right-click to display the shortcut menu and select Cut.
- Or press CTRL+X if the selection is within a text field.
Default action Removes the selection from the document and persists it in the clipboard.
Creating custom code for cutting requires several steps:
- Set event.returnValue=false in the onbeforecut event to enable the Cut shortcut menu item.
- Specify a data format in which to transfer the selection through the IHTMLDataTransfer::setData method of the clipboardData object.
- Invoke the IHTMLDataTransfer::setData method in the HTMLLabelEvents::oncut event.
Set event.returnValue=false in the HTMLLabelEvents::oncut event handler to cancel the default action. The default action must be canceled to successfully use the IHTMLDataTransfer::setData method. Web authors can use the IHTMLElement::innerHTML property or the IHTMLSelectionObject::createRange method to perform the cut operation once the event is canceled.