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