简体   繁体   中英

calling custom JavaScript function from codename one

I recently came across the JSObject and JSFuntion, and it seemed really confusing. Can it be used to call custom JavaScript functions and return values back to my CN1 app? Or is it for some other function?. Thanks all

Check out the javadoc package overview for that: https://www.codenameone.com/javadoc/com/codename1/javascript/package-summary.html

Eg from that page:

The following example shows an object with a simple add() method that just adds two numbers together:

JSObject obj = (JSObject)ctx.get("{ add : function(a,b){ return a+b;}}");
Double result = (Double)obj.call("add", 
    new Object[]{new Integer(1), new Integer(3)}
);

// Result should be 4.0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM