calling custom JavaScript function from codename one

给你一囗甜甜゛ 提交于 2019-12-10 12:24:57

问题


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


回答1:


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

E.g. 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


来源:https://stackoverflow.com/questions/39417360/calling-custom-javascript-function-from-codename-one

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!