Paste inside the canvas

There is already a previous question about this, but it is out of date. I did not find any help from the dartlang or googling site, so here again the problem.

document.onPaste.listen((e)  {
  //var items = e.clipboardData.getData("image"); 
  var blob = e.clipboardData.items.item(0).getAsFile();
  var reader = new FileReader();
  reader.onLoad.listen((e) {
    var img = new ImageElement()
    ..src = (e.target as FileReader).result;
    img.onLoad.listen((_) {
      mainContext.drawImage(img, 0, 0);
    });
  });
  reader.readAsDataUrl(blob);
});

"Elements" was the previous test, and "blob" should not work because google deleted item (). I have not found another way to do this. The last possible solution is to look for a javascript library for this. Please note that I use onPaste even for the entire document, because it did not work on the canvas, at least for me.

+4
source share
2 answers

. , , .

0
  @DomName('DataTransferItemList.__getter__')
  @DocsEditable()
  @Experimental() // untriaged
  DataTransferItem __getter__(int index) native "DataTransferItemList___getter___Callback";

.

URL-, :

var text = e.clipboardData.getData('text');

ClipboardData.types, , .

+1

All Articles