Chromium zoom 开发示例

This commit is contained in:
杨红岩 2023-02-07 13:20:33 +08:00
parent b4b7b41d98
commit d36f0ddab5
2 changed files with 36 additions and 0 deletions

View File

@ -86,6 +86,22 @@
<button onclick="find()">查找</button>
<button onclick="findStop()">停止查找</button>
<br>
<script>
function ZoomPct() {
ipc.emit("ZoomPct");
}
function ZoomLevel() {
ipc.emit("ZoomLevel");
}
function SetZoomStep() {
ipc.emit("SetZoomStep");
}
</script>
Chromium其它
<button onclick="ZoomPct()">ZoomPct</button>
<button onclick="ZoomLevel()">ZoomLevel</button>
<button onclick="SetZoomStep()">SetZoomStep</button>
<br>
UI操作
<button onclick="disabledUIBtn()">禁用打印PDF按钮</button>
<button onclick="ipcServerOn()">IPC Server ON测试</button>

View File

@ -51,6 +51,26 @@ func AppBrowserInit() {
//主进程 IPC事件
ipc.IPC.Browser().SetOnEvent(func(event ipc.IEventOn) {
fmt.Println("主进程IPC事件注册")
event.On("ZoomPct", func(context ipc.IIPCContext) {
fmt.Println("ZoomPct")
bw := cef.BrowserWindow.GetWindowInfo(context.BrowserId())
bw.Chromium().SetZoomPct(150.2)
fmt.Println(bw.Chromium().ZoomPct())
bw.Chromium().SetDefaultEncoding("UTF-8")
fmt.Println(bw.Chromium().DefaultEncoding())
})
event.On("ZoomLevel", func(context ipc.IIPCContext) {
fmt.Println("ZoomLevel")
bw := cef.BrowserWindow.GetWindowInfo(context.BrowserId())
bw.Chromium().SetZoomLevel(150.2)
fmt.Println(bw.Chromium().ZoomLevel())
})
event.On("SetZoomStep", func(context ipc.IIPCContext) {
fmt.Println("SetZoomStep")
bw := cef.BrowserWindow.GetWindowInfo(context.BrowserId())
bw.Chromium().SetZoomStep(1)
fmt.Println(bw.Chromium().ZoomStep())
})
//这个事件监听演示了几个示例
//1.
event.On("subWindowIPCOn", func(context ipc.IIPCContext) {