Add a public API to Mouse and Keyboard class, make it be able to set handlers of event in runtime.

This commit is contained in:
Fred Chien 2012-02-10 19:59:08 +08:00
parent 1af3e54bef
commit e7c5ffe5e8
1 changed files with 21 additions and 1 deletions

View File

@ -438,6 +438,16 @@ that.ungrab = function() {
//Util.Debug(">> Keyboard.ungrab"); //Util.Debug(">> Keyboard.ungrab");
}; };
that.set_handler = function(handlers) {
if (!handlers)
return;
for (var name in handlers) {
if (name == 'onKeyPress')
conf[name] = handlers[name];
}
};
return that; // Return the public API interface return that; // Return the public API interface
} // End of Keyboard() } // End of Keyboard()
@ -614,6 +624,16 @@ that.ungrab = function() {
//Util.Debug(">> Mouse.ungrab"); //Util.Debug(">> Mouse.ungrab");
}; };
that.set_handler = function(handlers) {
if (!handlers)
return;
for (var name in handlers) {
if (name == 'onMouseButton' || name == 'onMouseMove')
conf[name] = handlers[name];
}
};
return that; // Return the public API interface return that; // Return the public API interface
} // End of Mouse() } // End of Mouse()
@ -1881,4 +1901,4 @@ unicodeTable = {
0x28fd : 0x10028fd, 0x28fd : 0x10028fd,
0x28fe : 0x10028fe, 0x28fe : 0x10028fe,
0x28ff : 0x10028ff 0x28ff : 0x10028ff
}; };