Drag'n'Drop into Electron app is not allowed

我们两清 提交于 2019-12-11 17:06:03

问题


I am trying to implement Drag'n'Drop functionality for users to easier upload their images. In browser the drop area works perfectly but Electron is preventing files to be even dropped into the app. Every time I try to drop a file cursor changes to the one shown below and nothing happens.

I thought maybe Electron had configs to disable dropping files by default due to popular complain but I couldn't find any solution.

The picture shows the drop area, but the same issue is all across the app.

Main.js:

const { app, BrowserWindow } = require('electron')

let win

function createWindow () {
  win = new BrowserWindow({ width: 1000, height: 600, minWidth: 690, minHeight: 340 })

  win.loadFile('index.html')

  win.webContents.openDevTools()

  win.on('closed', () => {
    win = null
  })
}

app.on('ready', createWindow)

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

app.on('activate', () => {
  if (win === null) {
    createWindow()
  }
})

回答1:


Ok. That wasn't fun. Looks like something actually broke. But after I restarted the console, Windows then reinstalled the project, Electron, and NPM it finally worked. The problem is now solved.



来源:https://stackoverflow.com/questions/54522702/dragndrop-into-electron-app-is-not-allowed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!