[]
        
(Showing Draft Content)

Clipboard Class

Clipboard Class

Static class that provides utility methods for clipboard operations.

The Clipboard class provides static copy and paste methods that can be used by controls to customize the clipboard content during clipboard operations.

For example, the code below shows how a control could intercept the clipboard shortcut keys and provide custom clipboard handling:

rootElement.addEventListener('keydown', (e: KeyboardEvent) {

    // copy: ctrl+c or ctrl+Insert
    if (e.ctrlKey && (e.keyCode == 67 || e.keyCode == 45)) {
        let text = this.getClipString();
        Clipboard.copy(text);
        return;
    }

    // paste: ctrl+v or shift+Insert
    if ((e.ctrlKey && e.keyCode == 86) || (e.shiftKey && e.keyCode == 45)) {
        Clipboard.paste(text => {
            this.setClipString(text);
        });
        return;
     }
});

The example below shows how you can customize the behavior of the clipboard paste command when the target is a FlexGrid control:

Example

Heirarchy

  • Clipboard

Methods

Methods

Static copy

  • copy(text: string): void
  • Copies a string to the clipboard.

    This method only works if invoked immediately after the user pressed a clipboard copy command (such as ctrl+c).

    Parameters

    • text: string

      Text to copy to the clipboard.

    Returns void

Static paste

  • paste(callback: Function): void
  • Gets a string from the clipboard.

    This method only works if invoked immediately after the user pressed a clipboard paste command (such as ctrl+v).

    Parameters

    • callback: Function

      Function called when the clipboard content has been retrieved. The function receives the clipboard content as a parameter.

    Returns void