Atitit. D&d drag&drop drag file to interface function HTML5 web with a summary of Java Swing c#.net C + +

Source: Internet
Author: User

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 + +

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.