From 86273e767b5eb2160a7adfdad449a30045ac1524 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E7=BA=A2=E5=B2=A9?= Date: Tue, 27 Dec 2022 21:42:25 +0800 Subject: [PATCH] Ready to fix some problems on linux --- example/browser-tiny/tiny.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/example/browser-tiny/tiny.go b/example/browser-tiny/tiny.go index ba2c0007..8e6d3a8a 100644 --- a/example/browser-tiny/tiny.go +++ b/example/browser-tiny/tiny.go @@ -17,20 +17,24 @@ func main() { config.SetExternalMessagePump(false) //config.SetChromeRuntime(true) application := cef.NewCEFApplication(config) + application.SetOnContextCreated(func(browser *cef.ICefBrowser, frame *cef.ICefFrame, context *cef.ICefV8Context) bool { + fmt.Println("OnContextCreated") + return false + }) application.SetOnContextInitialized(func() { fmt.Println("OnContextInitialized()") component := lcl.NewComponent(nil) chromiumConfig := cef.NewChromiumConfig() chromium := cef.NewChromium(component, chromiumConfig) + browserViewComponent := cef.NewBrowserViewComponent(component) + windowComponent := cef.NewWindowComponent(component) chromium.SetOnBeforeClose(func(sender lcl.IObject, browser *cef.ICefBrowser) { fmt.Println("OnBeforeClose") - application.QuitMessageLoop() }) chromium.SetOnTitleChange(func(sender lcl.IObject, browser *cef.ICefBrowser, title string) { fmt.Println("OnTitleChange", title) + windowComponent.SetTitle(title) }) - browserViewComponent := cef.NewBrowserViewComponent(component) - windowComponent := cef.NewWindowComponent(component) windowComponent.SetOnWindowCreated(func(sender lcl.IObject, window *cef.ICefWindow) { fmt.Println("OnWindowCreated") b := chromium.CreateBrowserByBrowserViewComponent("https://www.baidu.com", browserViewComponent) @@ -43,7 +47,7 @@ func main() { }) windowComponent.SetOnCanClose(func(sender lcl.IObject, window *cef.ICefWindow, aResult *bool) { fmt.Println("OnCanClose") - chromium.TryCloseBrowser() + application.QuitMessageLoop() }) windowComponent.CreateTopLevelWindow()