energy/cef/types-accessibility-handler.go

87 lines
2.2 KiB
Go
Raw Normal View History

2023-05-31 17:41:14 +08:00
//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under Apache License Version 2.0, January 2004
//
// https://www.apache.org/licenses/LICENSE-2.0
//
//----------------------------------------
package cef
import (
"github.com/energye/energy/v2/cef/internal/def"
2023-05-31 18:00:34 +08:00
"github.com/energye/energy/v2/common/imports"
2023-05-31 17:41:14 +08:00
"github.com/energye/golcl/lcl"
"github.com/energye/golcl/lcl/api"
"unsafe"
)
// AccessibilityHandlerRef -> ICefAccessibilityHandler
var AccessibilityHandlerRef accessibilityHandler
type accessibilityHandler uintptr
func (*accessibilityHandler) New() *ICefAccessibilityHandler {
var result uintptr
imports.Proc(def.CefAccessibilityHandlerRef_Create).Call(uintptr(unsafe.Pointer(&result)))
2023-05-31 17:41:14 +08:00
if result != 0 {
return &ICefAccessibilityHandler{instance: unsafe.Pointer(result)}
}
return nil
}
// Instance 实例
func (m *ICefAccessibilityHandler) Instance() uintptr {
if m == nil {
return 0
}
return uintptr(m.instance)
}
func (m *ICefAccessibilityHandler) Free() {
if m.instance != nil {
m.base.Free(m.Instance())
m.instance = nil
}
}
func (m *ICefAccessibilityHandler) IsValid() bool {
if m == nil || m.instance == nil {
return false
}
return m.instance != nil
}
func (m *ICefAccessibilityHandler) SetOnAccessibilityTreeChange(fn onAccessibilityTreeChange) {
if !m.IsValid() {
return
}
imports.Proc(def.CefAccessibilityHandler_OnAccessibilityTreeChange).Call(m.Instance(), api.MakeEventDataPtr(fn))
2023-05-31 17:41:14 +08:00
}
func (m *ICefAccessibilityHandler) SetOnAccessibilityLocationChange(fn onAccessibilityLocationChange) {
if !m.IsValid() {
return
}
imports.Proc(def.CefAccessibilityHandler_OnAccessibilityLocationChange).Call(m.Instance(), api.MakeEventDataPtr(fn))
2023-05-31 17:41:14 +08:00
}
type onAccessibilityTreeChange func(value *ICefValue)
type onAccessibilityLocationChange func(value *ICefValue)
func init() {
lcl.RegisterExtEventCallback(func(fn interface{}, getVal func(idx int) uintptr) bool {
switch fn.(type) {
case onAccessibilityTreeChange:
fn.(onAccessibilityTreeChange)(&ICefValue{instance: getInstance(getVal(0))})
case onAccessibilityLocationChange:
fn.(onAccessibilityLocationChange)(&ICefValue{instance: getInstance(getVal(0))})
default:
return false
}
return true
})
}