Atitit. D & amp; D drag & amp; drop: drag the file to the html5 web page and summarize the java swing c #. net c ++,

Source: Internet
Author: User

Atitit. D & D drag & drop: drag a file to the interface function html5 web and a summary of java swing c #. net c ++,

Atitit. D & D drag & drop: drag a file to the interface function html5 web summary with a java swing c #. net c ++

 

1. DND operation process 1

2. Html5 annotation event document. dragover> preventDefault 1

3. Code (js) 1

4. C ++ implements drag 2

5. QT drag-and-drop feature-pcsuite column-blog channel-CSDN.NET.htm 2

 

 

1. DND operation procedure

Dragenter event: change the color of the prompt .. automatically change the cursor status to indicate whether the current control is a valid drop location

Dragleave event: change the color of the prompt.

Drop event: processing files... however, it seems that html sub-files can have file names, horse file paths ..

Note: Drag distance. If the distance is greater than the minimum drag Distance Determined by QApplication (usually four pixels), call the private function startDrag () to start dragging. The distance can be determined to avoid misoperation caused by the user's hand jitter.

 

Author: old wow's paw Attilax iron, EMAIL: 1466519819@qq.com

Reprinted please indicate Source: http://blog.csdn.net/attilax

 

2. Html5 annotation event document. dragover> preventDefault

PreventDefault () is called to prevent the browser from processing data by default (the default action of the drop event is to open in the form of 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 = 'sil ';

}, 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 ++ drag

Ya 10 enter with a drag event ..

Void MainWindow: dragEnterEvent (QDragEnterEvent * event)

{

If (event-> mimeData ()-> hasFormat ("text/uri-list "))

Event-> acceptProposedAction ();

}

Void MainWindow: dropEvent (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 garden .htm

5. QT drag-and-drop feature-pcsuite column-blog channel-CSDN.NET.htm

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.