本文整理汇总了Golang中github.com/oskca/sciter/window.Window类的典型用法代码示例。如果您正苦于以下问题:Golang Window类的具体用法?Golang Window怎么用?Golang Window使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Window类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: testCall
func testCall(w *window.Window) {
// test sciter call
v, err := w.Call("gFunc", sciter.NewValue("kkk"), sciter.NewValue(555))
if err != nil {
log.Println("sciter call failed:", err)
} else {
log.Println("sciter call successfully:", v.String())
}
// test method call
root, err := w.GetRootElement()
if err != nil {
log.Fatalf("get root element failed: %s", err.Error())
}
v, err = root.CallMethod("mfn", sciter.NewValue("method call"), sciter.NewValue(10300))
if err != nil {
log.Println("method call failed:", err)
} else {
log.Println("method call successfully:", v.String())
}
// test function call
v, err = root.CallFunction("gFunc", sciter.NewValue("function call"), sciter.NewValue(10300))
if err != nil {
log.Println("function call failed:", err)
} else {
log.Println("function call successfully:", v.String())
}
}
示例2: setCallbackHandlers
func setCallbackHandlers(w *window.Window) {
h := &sciter.CallbackHandler{
OnDataLoaded: func(ld *sciter.ScnDataLoaded) int {
log.Println("loaded", ld.Uri())
return sciter.LOAD_OK
},
OnLoadData: func(ld *sciter.ScnLoadData) int {
log.Println("loading", ld.Uri())
return sciter.LOAD_OK
},
}
w.SetCallback(h)
}
示例3: setEventHandler
func setEventHandler(w *window.Window) {
w.DefineFunction("getNetInformation", func(args ...*sciter.Value) *sciter.Value {
log.Println("Args Length:", len(args))
log.Println("Arg 0:", args[0], args[0].IsInt())
log.Println("Arg 1:", args[1], args[1].IsString())
log.Println("Arg 2: IsFunction", args[2], args[2].IsFunction())
log.Println("Arg 2: IsObjectFunction", args[2], args[2].IsObjectFunction())
log.Println("args[3].IsMap():", args[3].IsMap(), args[3].Length())
log.Println("args[3].IsObject():", args[3].IsObject(), args[3].Length(), args[3].Get("str"))
args[3].EnumerateKeyValue(func(key, val *sciter.Value) bool {
log.Println(key, val)
return true
})
fn := args[2]
fn.Invoke(sciter.NullValue(), "[Native Script]", sciter.NewValue("OK"))
ret := sciter.NewValue()
ret.Set("ip", sciter.NewValue("127.0.0.1"))
return ret
})
}
示例4: setEventHandler
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()
})
}
示例5: load
func load(w *window.Window, url string) {
root, err := w.GetRootElement()
if err != nil {
log.Panic(err)
}
els, err := root.Select("#url")
if err != nil {
log.Fatal("select:", err)
}
log.Println("els:", els)
span, _ := root.SelectById("url")
if span == nil {
log.Panic("span is nil")
}
content, _ := root.SelectById("content")
if content == nil {
log.Panic("content is nil")
}
text, err := span.Text()
if err != nil {
log.Panic(err)
}
log.Println("span:", text)
err = span.SetText(url)
if err != nil {
log.Panic(err)
}
content.AttachEventHandler(&sciter.EventHandler{
OnDataArrived: func(he *sciter.Element, params *sciter.DataArrivedParams) bool {
log.Println("uri:", params.Uri(), len(params.Data()))
return false
},
})
err = content.Load(url, sciter.RT_DATA_HTML)
if err != nil {
log.Panic(err)
}
}