提交 964b0bbb 编写于 作者: yanghye's avatar yanghye

U: CEFWindowParent, Add SetFocus, CanFocus Proc Api

上级 0f451654
......@@ -31,7 +31,7 @@ func createDevtoolsWindow(owner *LCLBrowserWindow) *devToolsWindow {
window.TForm = lcl.NewForm(owner)
window.SetCaption(devToolsName)
window.SetIcon(owner.Icon())
window.SetWindowParent(NewCEFWindow(window))
window.SetWindowParent(NewCEFWindowParent(window))
window.WindowParent().SetParent(window)
window.WindowParent().SetAlign(types.AlClient)
window.SetWidth(1024)
......
......@@ -25,7 +25,7 @@ type BaseWinControl struct {
// IsValid 是否有效
func (m *BaseWinControl) IsValid() bool {
return m.instance != nil
return m != nil && m.instance != nil
}
// Instance 当前实例
......
......@@ -504,6 +504,11 @@ func (m *LCLBrowserWindow) ChromiumCreate(config *TCefChromiumConfig, defaultUrl
}
m.Chromium().SendCaptureLostEvent()
})
m.Chromium().SetOnGotFocus(func(sender lcl.IObject, browser *ICefBrowser) {
if m.IsValid() {
m.WindowParent().SetFocus()
}
})
// 主窗口、子窗口chromium检测
if m.WindowProperty().WindowType != consts.WT_DEV_TOOLS {
window.CurrentBrowseWindowCache = m
......
......@@ -41,7 +41,7 @@ type TCEFChromiumBrowser struct {
func NewChromiumBrowser(owner lcl.IWinControl, config *TCefChromiumConfig) ICEFChromiumBrowser {
var m = new(TCEFChromiumBrowser)
m.chromium = NewChromium(owner, config)
m.windowParent = NewCEFWindow(owner)
m.windowParent = NewCEFWindowParent(owner)
m.windowParent.SetParent(owner)
m.windowParent.SetChromium(m.chromium, 0)
m.createTimer = lcl.NewTimer(owner)
......
......@@ -557,6 +557,8 @@ const (
CEFWindow_OnExit
CEFWindow_SetTag
CEFWindow_GetTag
CEFWindow_SetFocus
CEFWindow_CanFocus
// TCEFLinkedWindowParent
CEFLinkedWindow_Create
CEFLinkedWindow_GetHandle
......@@ -591,6 +593,8 @@ const (
CEFLinkedWindow_SetChromium
CEFLinkedWindow_SetTag
CEFLinkedWindow_GetTag
CEFLinkedWindow_SetFocus
CEFLinkedWindow_CanFocus
// ICefBrowser
CEFBrowser_ShowDevTools
CEFBrowser_CloseDevTools
......
......@@ -557,6 +557,8 @@ func init() {
dllimports.NewEnergyImport("CEFWindow_OnExit", 0),
dllimports.NewEnergyImport("CEFWindow_SetTag", 0),
dllimports.NewEnergyImport("CEFWindow_GetTag", 0),
dllimports.NewEnergyImport("CEFWindow_SetFocus", 0),
dllimports.NewEnergyImport("CEFWindow_CanFocus", 0),
//CEFLinkedParentWindow
dllimports.NewEnergyImport("CEFLinkedWindow_Create", 0),
dllimports.NewEnergyImport("CEFLinkedWindow_GetHandle", 0),
......@@ -591,6 +593,8 @@ func init() {
dllimports.NewEnergyImport("CEFLinkedWindow_SetChromium", 0),
dllimports.NewEnergyImport("CEFLinkedWindow_SetTag", 0),
dllimports.NewEnergyImport("CEFLinkedWindow_GetTag", 0),
dllimports.NewEnergyImport("CEFLinkedWindow_SetFocus", 0),
dllimports.NewEnergyImport("CEFLinkedWindow_CanFocus", 0),
//ICefBrowser
dllimports.NewEnergyImport("CEFBrowser_ShowDevTools", 0),
dllimports.NewEnergyImport("CEFBrowser_CloseDevTools", 0),
......
......@@ -231,7 +231,7 @@ func (m *CEFTray) createTrayWindow() {
})
}
})
m.windowParent = NewCEFWindow(m.TForm)
m.windowParent = NewCEFWindowParent(m.TForm)
m.windowParent.SetParent(m.TForm)
m.windowParent.SetAlign(types.AlClient)
m.windowParent.SetAnchors(types.NewSet(types.AkTop, types.AkLeft, types.AkRight, types.AkBottom))
......
......@@ -13,13 +13,14 @@
package cef
import (
"github.com/energye/energy/v2/common"
"github.com/energye/energy/v2/consts"
"github.com/energye/golcl/lcl"
"github.com/energye/golcl/lcl/types"
)
// ICEFWindowParent 接口定义
// Windows return TCEFWindowParent
// MacOSX, Linux return TCEFLinkedWindowParent
type ICEFWindowParent interface {
lcl.IWinControl
Instance() uintptr
......@@ -58,17 +59,6 @@ type ICEFWindowParent interface {
SetBoundsRect(value types.TRect) // 设置矩形边界
point() (x, y int32) // 坐标点
size() (w, h int32) // 大小
}
// NewCEFWindow 创建CEFWindowParent
//
// # Windows return TCEFWindowParent
//
// MacOSX, Linux return TCEFLinkedWindowParent
func NewCEFWindow(owner lcl.IComponent) ICEFWindowParent {
if common.IsWindows() {
return NewCEFWindowParent(owner)
} else {
return NewCEFLinkedWindowParent(owner)
}
SetFocus() //
CanFocus() bool //
}
......@@ -8,6 +8,8 @@
//
//----------------------------------------
//go:build !windows
// CEFWindowParent组件
// MacOSX, Linux
......@@ -29,8 +31,8 @@ type TCEFLinkedWindowParent struct {
x, y, w, h int32
}
// NewCEFLinkedWindowParent 创建一个新的WindowParent组件
func NewCEFLinkedWindowParent(owner lcl.IComponent) *TCEFLinkedWindowParent {
// NewCEFWindowParent 创建一个新的 TCEFLinkedWindowParent 组件
func NewCEFWindowParent(owner lcl.IComponent) *TCEFLinkedWindowParent {
m := new(TCEFLinkedWindowParent)
r1, _, _ := imports.Proc(def.CEFLinkedWindow_Create).Call(lcl.CheckPtr(owner))
m.instance = unsafe.Pointer(r1)
......@@ -248,3 +250,12 @@ func (m *TCEFLinkedWindowParent) point() (x, y int32) {
func (m *TCEFLinkedWindowParent) size() (w, h int32) {
return m.w, m.h
}
func (m *TCEFLinkedWindowParent) SetFocus() {
imports.Proc(def.CEFWindow_SetFocus).Call(m.Instance())
}
func (m *TCEFLinkedWindowParent) CanFocus() bool {
r1, _, _ := imports.Proc(def.CEFWindow_CanFocus).Call(m.Instance())
return api.GoBool(r1)
}
......@@ -8,6 +8,8 @@
//
//----------------------------------------
//go:build windows
package cef
import (
......@@ -26,7 +28,7 @@ type TCEFWindowParent struct {
x, y, w, h int32
}
// NewCEFWindowParent 创建一个新的WindowParent组件
// NewCEFWindowParent 创建一个新的 TCEFWindowParent 组件
func NewCEFWindowParent(owner lcl.IComponent) *TCEFWindowParent {
m := new(TCEFWindowParent)
r1, _, _ := imports.Proc(def.CEFWindow_Create).Call(lcl.CheckPtr(owner))
......@@ -244,3 +246,12 @@ func (m *TCEFWindowParent) point() (x, y int32) {
func (m *TCEFWindowParent) size() (w, h int32) {
return m.w, m.h
}
func (m *TCEFWindowParent) SetFocus() {
imports.Proc(def.CEFLinkedWindow_SetFocus).Call(m.Instance())
}
func (m *TCEFWindowParent) CanFocus() bool {
r1, _, _ := imports.Proc(def.CEFLinkedWindow_CanFocus).Call(m.Instance())
return api.GoBool(r1)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册