Skip to main content
September 30, 2010
Answered

How to ensure CutOperation puts the cut text on the clipboard?

  • September 30, 2010
  • 1 reply
  • 513 views

I have a class that inherits from EditManager and provides these methods:

public function performCopy():void

{

var copyOperation:CopyOperation = new CopyOperation( getSelectionState() );

doOperation( copyOperation );

}

public function performCut():void

{

var textToCut:TextScrap = TextScrap.createTextScrap( getSelectionState() );

var cutOperation:CutOperation = new CutOperation( getSelectionState(), textToCut );

doOperation( cutOperation );

}

PerformCopy works fine and puts the copied text on the clipboard.

PerformCut removes the text as expected but does not put it on the clipboard.

The CutOperation documentation says "The edit manager is responsible for copying the text scrap to the clipboard. Undoing a cut operation does not restore the original clipboard state."

Any idea what I might be doing wrong?

Thanks

Stefan

This topic has been closed for replies.
Correct answer robin_briggs

You can call TextClipboard.setContents(textScrap) to put the scrap you made up to the system clipboard. For an example of how this is done in TLF, see EditManager.as editHandler function. Note that this can only be done in the context of an CUT or COPY event, unless you are running on AIR (accessing the clipboard is subject to security sandbox).

Hope this helps,

- robin

1 reply

robin_briggsCorrect answer
Adobe Employee
October 1, 2010

You can call TextClipboard.setContents(textScrap) to put the scrap you made up to the system clipboard. For an example of how this is done in TLF, see EditManager.as editHandler function. Note that this can only be done in the context of an CUT or COPY event, unless you are running on AIR (accessing the clipboard is subject to security sandbox).

Hope this helps,

- robin

October 1, 2010

Thanks Robin.

Yeah - I figured that one. It just comes down to me expecting CutOperation to work differently.