new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Electron · API · all subjects

webcontents: editing & drag-drop

5 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

webContents.startDrag() API for dragging files out

To implement native file drag & drop for dragging files out from web content into the operating system, call the webContents.startDrag(item) API in response to the ondragstart event.

startDrag() method signature and parameters

The webContents.startDrag(item) method accepts an item object with the following properties: file (the path to the file being dragged) and icon (the path to the icon file to display during the drag).

Renderer process drag event handling example

In the renderer process, listen to the ondragstart event on a draggable element and call event.preventDefault(), then invoke window.electron.startDrag(fileName) to initiate the drag operation.

Main process drag event handling example

In the main process, listen to the 'ondragstart' IPC message, then call event.sender.startDrag() with an object containing the file path and icon path to complete the drag operation.

Standard Drag and Drop web API for dragging files into app

For dragging files into your Electron app, use the standard Drag and Drop web API as defined by MDN, which is supported by Electron.

Give your agent this brain