add events module, including EventEmiiter, KeyEvent, TouchEvent

This commit is contained in:
hyb1996
2017-07-20 15:39:17 +08:00
parent 1d23640362
commit 52cc5214f1
47 changed files with 755 additions and 82 deletions

View File

@@ -27,7 +27,7 @@ require("__general__")(__runtime__, this);
(function(scope){
var modules = ['app', 'automator', 'console', 'dialogs', 'io', 'selector', 'shell', 'web', 'ui', "images"];
var modules = ['app', 'automator', 'console', 'dialogs', 'io', 'selector', 'shell', 'web', 'ui', "images", "events"];
var len = modules.length;
for(var i = 0; i < len; i++) {
var m = modules[i];

View File

@@ -0,0 +1,24 @@
module.exports = function(__runtime__, scope){
var events = Object.create(__runtime__.events);
var caller = function(func, args){
var arr = [];
var len = args.length;
for(var i = 0; i < len; i++){
arr.push(args[i]);
}
return func.apply(null, arr);
};
events.setFunctionCaller(caller);
events.emitter = function(){
var e = new com.stardust.autojs.runtime.api.EventEmitter();
e.setFunctionCaller(caller);
return e;
}
return events;
}

View File

@@ -9,9 +9,7 @@ module.exports = function(__runtime__, scope){
scope.log(text);
}
scope.sleep = function(millis){
__runtime__.sleep(millis);
}
scope.sleep = __runtime__.sleep.bind(__runtime__);
scope.isStopped = function(){
return __runtime__.isStopped();