forked from mikeseven/node-glfw
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
30 lines (26 loc) · 897 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('./build/Release/glfw.node');
// make sure cursor is always visible
//GLFW.Enable(GLFW.MOUSE_CURSOR);
// 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);
};
return events;
},
enumerable: true,
configurable: true
});