forked from mikeseven/node-glfw
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
29 lines (27 loc) · 910 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var GLFW = module.exports = require('bindings')('glfw');
// Easy event emitter based event loop. Started automatically when the first
// listener is added.
var events;
Object.defineProperty(GLFW, 'events', {
get: function () {
if (events) return events;
events = new (require('events').EventEmitter);
var _emit=events.emit;
events.emit=function() {
var args = Array.prototype.slice.call(arguments);
var evt= args[1]; // args[1] is the event, args[0] is the type of event
//console.log("emitting event: "+require('util').inspect(args));
if(args[0] != 'quit') {
evt.preventDefault = function () {};
evt.stopPropagation = function () {};
}
//_emit.apply(this,args);
events.listeners(args[0]).forEach(function(listener) {
listener(args[1]);
});
};
return events;
},
enumerable: true,
configurable: true
});