Search Unity

PowerUI Jint not setting onclick = function ??

Discussion in 'Scripting' started by yaakovyitzchakbenmoshe, May 10, 2019.

  1. yaakovyitzchakbenmoshe

    yaakovyitzchakbenmoshe

    Joined:
    Feb 9, 2018
    Posts:
    21
    Hi,

    I'm trying to use PowerUI with the JavaScript Jint to make a button clickable, very simple in regular HTML:

    Code (JavaScript):
    1.     PowerUI.UI.Html = ( "<!doctype html><html><head><style>body,html{background:green; color:black;}</style></head><body>var b= document.createElement('b'); b.innerHTML = 'CLICK me maybe'; b.onclick=function(e,u) {console.log(234);}; document.body.appendChild(b);</body></html>");
    If I just use reuglar HTML (without Jint) and say <button onclick="whatever">.... works fine, only when assigning b.onclick = function(){}, do I get an error:
    Code (Boo):
    1.  
    2.     JavaScript compile error  (At resources://): System.ArgumentException: Object of type 'System.Func`2[PowerUI.MouseEvent,System.Object]' cannot be converted to type 'System.Action`1[PowerUI.MouseEvent]'.
    3.       at System.RuntimeType.CheckValue (System.Object value, System.Reflection.Binder binder, System.Globalization.CultureInfo culture, System.Reflection.BindingFlags invokeAttr) [0x00071] in <23c160f925be47d7a4fd083a3a62c920>:0
    4.       at System.Reflection.MonoMethod.ConvertValues (System.Reflection.Binder binder, System.Object[] args, System.Reflection.ParameterInfo[] pinfo, System.Globalization.CultureInfo culture, System.Reflection.BindingFlags invokeAttr) [0x00069] in <23c160f925be47d7a4fd083a3a62c920>:0
    5.       at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00011] in <23c160f925be47d7a4fd083a3a62c920>:0
    6.       at System.Reflection.MonoProperty.SetValue (System.Object obj, System.Object value, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] index, System.Globalization.CultureInfo culture) [0x0005d] in <23c160f925be47d7a4fd083a3a62c920>:0
    7.       at System.Reflection.PropertyInfo.SetValue (System.Object obj, System.Object value, System.Object[] index) [0x00000] in <23c160f925be47d7a4fd083a3a62c920>:0
    8.       at Jint.Runtime.Descriptors.Specialized.PropertyInfoDescriptor.set_Value (Jint.Native.JsValue value) [0x00074] in C:\Users\eivan\OneDrive\Documents\unitys\project\Achdus\Assets\PowerUI\Source\JavaScript\Jint\Runtime\Descriptors\Specialized\PropertyInfoDescriptor.cs:47
    9.       at Jint.Runtime.Interop.ObjectWrapper.Put (System.String propertyName, Jint.Native.JsValue value, System.Boolean throwOnError) [0x00061] in C:\Users\eivan\OneDrive\Documents\unitys\project\Achdus\Assets\PowerUI\Source\JavaScript\Jint\Runtime\Interop\ObjectWrapper.cs:50
    10.       at Jint.Engine.PutValue (Jint.Runtime.References.Reference reference, Jint.Native.JsValue value) [0x0005f] in C:\Users\eivan\OneDrive\Documents\unitys\project\Achdus\Assets\PowerUI\Source\JavaScript\Jint\Engine.cs:592
    11.       at Jint.Runtime.ExpressionInterpreter.EvaluateAssignmentExpression (Jint.Parser.Ast.AssignmentExpression assignmentExpression) [0x000ab] in C:\Users\eivan\OneDrive\Documents\unitys\project\Achdus\Assets\PowerUI\Source\JavaScript\Jint\Runtime\ExpressionIntepreter.cs:61
    12.       at Jint.Engine.EvaluateExpression (Jint.Parser.Ast.Expression expression) [0x00099] in C:\Users\eivan\OneDrive\Documents\unitys\project\Achdus\Assets\PowerUI\Source\JavaScript\Jint\Engine.cs:444
    13.       at Jint.Runtime.StatementInterpreter.ExecuteExpressionStatement (Jint.Parser.Ast.ExpressionStatement expressionStatement) [0x00001] in C:\Users\eivan\OneDrive\Documents\unitys\project\Achdus\Assets\PowerUI\Source\JavaScript\Jint\Runtime\StatementInterpreter.cs:33
    14.       at Jint.Engine.ExecuteStatement (Jint.Parser.Ast.Statement statement) [0x001ca] in C:\Users\eivan\OneDrive\Documents\unitys\project\Achdus\Assets\PowerUI\Source\JavaScript\Jint\Engine.cs:391
    15.       at Jint.Runtime.StatementInterpreter.ExecuteStatement (Jint.Parser.Ast.Statement statement) [0x00001] in C:\Users\eivan\OneDrive\Documents\unitys\project\Achdus\Assets\PowerUI\Source\JavaScript\Jint\Runtime\StatementInterpreter.cs:23
    16.       at Jint.Runtime.StatementInterpreter.ExecuteStatementList (System.Collections.Generic.IEnumerable`1[T] statementList) [0x00029] in C:\Users\eivan\OneDrive\Documents\unitys\project\Achdus\Assets\PowerUI\Source\JavaScript\Jint\Runtime\StatementInterpreter.cs:425
    17.       at Jint.Runtime.StatementInterpreter.ExecuteProgram (Jint.Parser.Ast.Program program) [0x00001] in C:\Users\eivan\OneDrive\Documents\unitys\project\Achdus\Assets\PowerUI\Source\JavaScript\Jint\Runtime\StatementInterpreter.cs:503
    18.       at Jint.Engine.Execute (Jint.Parser.Ast.Program program) [0x00051] in C:\Users\eivan\OneDrive\Documents\unitys\project\Achdus\Assets\PowerUI\Source\JavaScript\Jint\Engine.cs:322
    19.       at Jint.Engine.Execute (System.String source) [0x00007] in C:\Users\eivan\OneDrive\Documents\unitys\project\Achdus\Assets\PowerUI\Source\JavaScript\Jint\Engine.cs:302
    20.       at PowerUI.JavaScriptEngine.Compile (System.String source) [0x0001a] in C:\Users\eivan\OneDrive\Documents\unitys\project\Achdus\Assets\PowerUI\Source\JavaScript\JavaScriptEngine.cs:213
    21.     UnityEngine.Debug:Log(Object)
    22.     PowerUI.UI:OnLogMessage(String) (at Assets/PowerUI/Source/Engine/UI.cs:430)
    23.     Dom.Log:Add(String) (at Assets/PowerUI/Source/Dom/Log.cs:34)
    24.     PowerUI.JavaScriptEngine:Compile(String) (at Assets/PowerUI/Source/JavaScript/JavaScriptEngine.cs:237)
    25.     PowerUI.ScriptEngine:TryCompile() (at Assets/PowerUI/Source/Engine/Script Engines/ScriptEngine.cs:163)
    26.     PowerUI.HtmlDocument:TryCompile() (at Assets/PowerUI/Source/Engine/Document/Document-Scripting.cs:98)
    27.     PowerUI.HtmlDocument:close() (at Assets/PowerUI/Source/Engine/Document/Document.cs:297)
    28.     PowerUI.HtmlDocument:set_innerHTML(String) (at Assets/PowerUI/Source/Engine/Document/Document.cs:697)
    29.     PowerUI.UI:set_Html(String) (at Assets/PowerUI/Source/Engine/UI.cs:715)
    30.     Achdus.Yaakov:CompileJavaScript(String) (at Assets/COBY.cs:323)
    31.     COBY:Start() (at Assets/COBY.cs:311)

    This also happens when I try to pass other functions as arguments etc....

    does anyone know a fix for this, possibly involving the powerUI source code?