func setEventHandler(w *window.Window) { w.DefineFunction("kkk", func(args ...*sciter.Value) *sciter.Value { log.Println("kkk called!") rval := sciter.NewValue() rval.Set("num", sciter.NewValue(1000)) rval.Set("str", sciter.NewValue("a string")) var fn sciter.NativeFunctor fn = func(args ...*sciter.Value) *sciter.Value { log.Printf("args[%d]:%v\n", len(args), args) return sciter.NewValue("native functor called") } rval.Set("f", sciter.NewValue(fn)) return rval }) w.DefineFunction("sumall", func(args ...*sciter.Value) *sciter.Value { sum := 0 for i := 0; i < len(args); i++ { sum += args[i].Int() } return sciter.NewValue(sum) }) w.DefineFunction("gprintln", func(args ...*sciter.Value) *sciter.Value { print("\t->") for _, arg := range args { print(arg.String(), "\t") } println() return sciter.NullValue() }) }
func setElementHandlers(root *sciter.Element) { log.Println("setElementHandlers") el, err := root.SelectFirst("#native") if err == nil { log.Println("SelectFirst:", el) el.OnClick(func() { log.Println("native handler called") }) } root.DefineMethod("mcall", func(args ...*sciter.Value) *sciter.Value { print("->method args:") for _, arg := range args { print(arg.String(), "\t") } println() return sciter.NullValue() }) }