本文整理匯總了Golang中github.com/oskca/sciter/window.Window.GetRootElement方法的典型用法代碼示例。如果您正苦於以下問題:Golang Window.GetRootElement方法的具體用法?Golang Window.GetRootElement怎麽用?Golang Window.GetRootElement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/oskca/sciter/window.Window
的用法示例。
在下文中一共展示了Window.GetRootElement方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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)
}
}