AppJS拖放事件永远不会被触发
使用基本上给NodeJS一个webkit窗口的AppJS( http://appjs.org/ )。 我试图利用拖放事件的文件和URL在我的代码中使用。
拖放的简短代码可以在这里find: https : //github.com/appjs/appjs/wiki/HTML5 : -Drag-&- Drop- from-Desktop
我用来创build窗口的代码:
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处于起步阶段,但这应该起作用。
可能是什么问题呢? 为什么事件从未解雇?
我不完全确定你的方法不工作,但尝试我使用的方法(和它的工作原理): –
在你的主html中,在那里添加脚本标记,然后在app-ready事件中附加你的drop事件,如下所示:
addEventListener('app-ready', function(e){ window.addEventListener("drop", window_drop); window.dispatchEvent(new Event('app-done')); });