add events module, including EventEmiiter, KeyEvent, TouchEvent
This commit is contained in:
24
autojs/src/main/assets/modules/__events__.js
Normal file
24
autojs/src/main/assets/modules/__events__.js
Normal 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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user