diff --git a/docs/fiddles/native-ui/drag-and-drop/index.html b/docs/fiddles/native-ui/drag-and-drop/index.html new file mode 100644 index 0000000000000..40f2733cd266d --- /dev/null +++ b/docs/fiddles/native-ui/drag-and-drop/index.html @@ -0,0 +1,76 @@ + + +
+ ++ Open the + + full API documentation (opens in new window) + + in your browser. +
++ Click and drag the link above to copy the renderer process + javascript file on to your machine. +
+ +
+ In this demo, the webContents.startDrag()
API is called
+ in response to the ondragstart
event.
+
+const {ipcRenderer} = require('electron')
+
+const dragFileLink = document.getElementById('drag-file-link')
+
+dragFileLink.addEventListener('dragstart', (event) => {
+ event.preventDefault()
+ ipcRenderer.send('ondragstart', __filename)
+})
+
+
+
+const {ipcMain} = require('electron')
+const path = require('path')
+
+ipcMain.on('ondragstart', (event, filepath) => {
+ const iconName = 'codeIcon.png'
+ event.sender.startDrag({
+ file: filepath,
+ icon: path.join(__dirname, iconName)
+ })
+})
+
+