I saw the webs and I am still confused. If I use us I cannot get the drag data(I guess chrome deal with drag itself so when we drag some text or link to input element it will accept the text or link text).
How to get the drag data? So I can judge whether it is a link or text by JS ?
How to know if the text was accepted by the target? So I can operate it if it is not accept by target element.
Thank you!
Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
StartDragging doesn't be trigged
- salvadordf
- Posts: 4580
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: StartDragging doesn't be trigged
Chromium doesn't expose all the information in normal mode.
If you need that information I would suggest to use a browser in OSR mode.
...unless there's a way in JavaScript to intercept that. I'm not a JavaScript expert and I could be wrong.
If you need that information I would suggest to use a browser in OSR mode.
...unless there's a way in JavaScript to intercept that. I'm not a JavaScript expert and I could be wrong.
Re: StartDragging doesn't be trigged
Code: Select all
var Mydroptagetobjint = 0;
var MyUrlTxt1= "";
var MyTxt1= "";
document.addEventListener("dragstart", function(event)
{
event.dataTransfer.setData("Text", window.getSelection().toString());
MyTxt1 = window.getSelection().toString();
if (event.target && event.target.href )
{
event.dataTransfer.setData("Url", event.target.href);
MyUrlTxt1 = event.target.href;
}
});
document.addEventListener("dragend", function(event)
{
if ( Mydroptagetobjint != 4 )
{
if ( MyTxt1 !="" )
{
window.open("https://www.baidu.com/s?wd=" + MyTxt1, "_blank");
} else if ( MyUrlTxt1 !="" )
{
window.open(MyUrlTxt1, "_blank");
}
}
Mydroptagetobjint = 0;
MyUrlTxt1= "";
MyTxt1= "";
});
document.addEventListener("drop", function(event)
{
if (event.target && event.target.tagName && ["TEXTAREA", "INPUT"].includes(event.target.tagName) )
{
Mydroptagetobjint = 4;
}
else
{
Mydroptagetobjint = 5;
}
});
Now I resolve the problem, but I have another question.
How to accept drag text(url) from another application? Chrome can operate it, but cef4 doesn't.
- salvadordf
- Posts: 4580
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: StartDragging doesn't be trigged
I guess that's a JavaScript question and I'm not an expert, sorry.
Consider using a browser in OSR mode to have full control over drag and drop from Delphi.
Consider using a browser in OSR mode to have full control over drag and drop from Delphi.