使用 AppJS ( http://appjs.org/ ),它基本上为 NodeJS 提供了一个可以使用的 webkit 窗口。我正在尝试利用拖放事件来处理要在我的代码中使用的文件和 URL。
拖放的简短代码可以在这里找到:https ://github.com/appjs/appjs/wiki/HTML5:-Drag-&-Drop-from-Desktop
我用来创建窗口的代码:
var app_window = appjs.createWindow({
  width  : 200,
  height : 200,
  showChrome : true, //display as standard os window with max/min/close buttons
  alpha: false,
  autoResize: true,  //adjust window size automatically according to content.
  resizable: true,   //allow user resize of window
  margin: 0,
  disableSecurity:true, //turn off security restrictions.
  showResizeGrip:false, //show/hide the resize grip.
  name:'Drag and Drop',   //undocumented parameter
  opacity:1,
  fullscreen:false,
  topmost:true
});
事件处理程序代码:
var window_drop = function(event) { // this code never fires.
  event.preventDefault();
  console.log('drop event');
};
以及我为触发事件而设置的代码:
app_window.on('ready', function() {
  app_window.require = require;
  app_window.process = process;
  app_window.module = module;
  app_window.console = console;
  app_window.frame.show();
  app_window.frame.center();
  app_window.addEventListener("drop", window_drop);
});
规格:我在 Mac OSX Lion 上运行 NodeJS 32 位(AppJS 要求)。
我知道 AppJS 还处于起步阶段,但这应该可以。
可能是什么问题呢?为什么该事件从未触发?