Atitit. D&d drag&drop Drag file to interface function HTML5 web with a summary of java Swing c#.net C + +
1. DND operation Flow 1
2. HTML5 Annotation Event document.dragover >>preventdefault 1
3. Code (JS) 1
4. C + + implementation Drag 2
5. Introduction to QT drag function -pcsuite 's Column - Blog channel -CSDN.NET.htm 2
1. DNDthe operational process
Dragenter Event:: Change the color of the prompt ... Automatically change cursor status indicates whether the user's current control is a valid drop location
DragLeave Event:: Change the color of the hint.
Drop Event: Process file. However, it seems that HTML child can have file name, horse file path:
Note::: Drag distance, if this distance is greater than the minimum distance of qapplication determined drag (usually four pixels), call private Function StartDrag () to start dragging. By judging the distance can be avoided because the user hand jitter caused by the wrong operation
Author :: Old Wow's paw attilax ayron, email:[email protected]
Reprint please indicate source: Http://blog.csdn.net/attilax
2. HTML5Annotation EventsDocument.dragover >>preventdefault
Call Preventdefault () to avoid browser default handling of data (the default behavior of the drop event is to open as a link)
3. Code(JS)
<script>
Handlefiles = function (files) {
for (var i = 0; i < files.length; i++) {
var file = Files[i];
Alert ("AA" +file);
}
}
Document.addeventlistener ("DragEnter", function (e) {
Dropbox.style.borderColor = ' Gray ';
}, False);
Document.addeventlistener ("DragLeave", function (e) {
Dropbox.style.borderColor = ' Silver ';
}, False);
Document.addeventlistener ("DragOver", function (e) {
E.stoppropagation ();
E.preventdefault ();
}, False);
Document.addeventlistener ("Drop", function (e) {
E.stoppropagation ();
E.preventdefault ();
alert (e.datatransfer.files);
Handlefiles (E.datatransfer.files);
submit.disabled = false;
}, False);
4. C + +Implement Drag
Jas. 10 Enter with a drag event .
void MainWindow::d ragenterevent (qdragenterevent *event)
{
if (Event->mimedata ()->hasformat ("Text/uri-list"))
Event->acceptproposedaction ();
}
void MainWindow::d ropevent (qdropevent *event)
{
qlist<qurl> urls = Event->mimedata ()->urls ();
if (Urls.isempty ())
Return
QString fileName = Urls.first (). Tolocalfile ();
if (Filename.isempty ())
Reference
HTML5 file Implementation Drag-and-drop upload-caonidayecnblogs-blog Park. htm
5. QTIntroduction to drag and drop functions-Pcsuite's Column- Blog Channel-CSDN.NET.htm
Atitit. D&d drag&drop drag file to interface function HTML5 web with a summary of Java Swing c#.net C + +