Perform actions with drag and drop
Posted: Mon Nov 29, 2021 5:57 pm
Hello,
I created a custom side view in OWA with buttons to perform specific actions (insert XML fragment) on click. It works well.
I would like also to perform these actions when I drag and drop these buttons on document.
So I add a listener on my buttons:
And after I tried to execute operation on drop event:
But nothing appends
Maybe the drop event is not defined at the right place?
Thanks for your help.
Regards,
Nicolas
I created a custom side view in OWA with buttons to perform specific actions (insert XML fragment) on click. It works well.
I would like also to perform these actions when I drag and drop these buttons on document.
So I add a listener on my buttons:
Code: Select all
button.addEventListener( "dragstart" , function(e){drag(e,name);});
Code: Select all
//drag event
function drag(ev,name) {
ev.dataTransfer.setData("text", name);
}
//drop event
function drop(ev) {
ev.preventDefault();
var data = ev.dataTransfer.getData("text");
editor.getActionsManager().invokeOperation(
'ro.sync.ecss.extensions.commons.operations.ExecuteMultipleActionsOperation',
{ actionIDs: 'insert_' + data },
function () {
console.log('Done!');
}
);
}
//add drop event on body
document.getElementsByTagName("body")[0].addEventListener( "drop" , function(e){drop(e);});
Maybe the drop event is not defined at the right place?
Thanks for your help.
Regards,
Nicolas