mirror of
https://gitee.com/energye/energy.git
synced 2024-12-02 11:47:37 +08:00
Fix: Chromium & DialogHandler onFileDialog callback args:acceptFiltersList
This commit is contained in:
parent
981751a3b0
commit
b89c3bd57c
@ -61,7 +61,7 @@ type chromiumEventOnExtensionLoaded func(sender lcl.IObject, extension *ICefExte
|
||||
type chromiumEventOnExtensionLoadFailed func(sender lcl.IObject, result consts.TCefErrorCode)
|
||||
type chromiumEventOnExtensionUnloaded func(sender lcl.IObject, extension *ICefExtension)
|
||||
type chromiumEventOnFavIconUrlChange func(sender lcl.IObject, browser *ICefBrowser, iconUrls []string) // TStrings => []string
|
||||
type chromiumEventOnFileDialog func(sender lcl.IObject, browser *ICefBrowser, mode consts.TCefFileDialogMode, title, defaultFilePath string, acceptFilters []string, callback *ICefFileDialogCallback) bool
|
||||
type chromiumEventOnFileDialog func(sender lcl.IObject, browser *ICefBrowser, mode consts.FileDialogMode, title, defaultFilePath string, acceptFilters *lcl.TStrings, callback *ICefFileDialogCallback) bool
|
||||
type chromiumEventOnGetAccessibilityHandler func(sender lcl.IObject, accessibilityHandler *ICefAccessibilityHandler)
|
||||
type chromiumEventOnGetAudioParameters func(sender lcl.IObject, browser *ICefBrowser, params *TCefAudioParameters) bool
|
||||
type chromiumEventOnGetResourceHandler func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, request *ICefRequest) (resourceHandler *ICefResourceHandler)
|
||||
|
@ -310,22 +310,22 @@ func init() {
|
||||
fn.(chromiumEventOnFavIconUrlChange)(lcl.AsObject(getPtr(0)), browse, iconUrls)
|
||||
case chromiumEventOnFileDialog:
|
||||
browse := &ICefBrowser{instance: getPtr(1)}
|
||||
mode := consts.TCefFileDialogMode(getVal(2))
|
||||
mode := consts.FileDialogMode(getVal(2))
|
||||
title := api.GoStr(getVal(3))
|
||||
defaultFilePath := api.GoStr(getVal(4))
|
||||
acceptFiltersList := lcl.AsStrings(getVal(5))
|
||||
callback := &ICefFileDialogCallback{instance: getPtr(6)}
|
||||
result := (*bool)(getPtr(7))
|
||||
var acceptFilters []string
|
||||
if acceptFiltersList.IsValid() {
|
||||
count := int(acceptFiltersList.Count())
|
||||
acceptFilters = make([]string, count, count)
|
||||
for i := 0; i < count; i++ {
|
||||
acceptFilters[i] = acceptFiltersList.Strings(int32(i))
|
||||
}
|
||||
acceptFiltersList.Free()
|
||||
}
|
||||
*result = fn.(chromiumEventOnFileDialog)(lcl.AsObject(getPtr(0)), browse, mode, title, defaultFilePath, acceptFilters, callback)
|
||||
//var acceptFilters []string
|
||||
//if acceptFiltersList.IsValid() {
|
||||
// count := int(acceptFiltersList.Count())
|
||||
// acceptFilters = make([]string, count, count)
|
||||
// for i := 0; i < count; i++ {
|
||||
// acceptFilters[i] = acceptFiltersList.Strings(int32(i))
|
||||
// }
|
||||
// //acceptFiltersList.Free()
|
||||
//}
|
||||
*result = fn.(chromiumEventOnFileDialog)(lcl.AsObject(getPtr(0)), browse, mode, title, defaultFilePath, acceptFiltersList, callback)
|
||||
case chromiumEventOnGetAccessibilityHandler:
|
||||
accessibilityHandler := &ICefAccessibilityHandler{instance: getPtr(1)}
|
||||
fn.(chromiumEventOnGetAccessibilityHandler)(lcl.AsObject(getPtr(0)), accessibilityHandler)
|
||||
|
@ -68,7 +68,7 @@ func (m *ICefDialogHandler) SetOnFileDialog(fn onFileDialog) {
|
||||
|
||||
// ************************** events ************************** //
|
||||
|
||||
type onFileDialog func(browser *ICefBrowser, mode consts.TCefFileDialogMode, title, defaultFilePath string, acceptFilters []string, callback *ICefFileDialogCallback) bool
|
||||
type onFileDialog func(browser *ICefBrowser, mode consts.FileDialogMode, title, defaultFilePath string, acceptFilters *lcl.TStrings, callback *ICefFileDialogCallback) bool
|
||||
|
||||
func init() {
|
||||
lcl.RegisterExtEventCallback(func(fn interface{}, getVal func(idx int) uintptr) bool {
|
||||
@ -78,22 +78,13 @@ func init() {
|
||||
switch fn.(type) {
|
||||
case onFileDialog:
|
||||
browse := &ICefBrowser{instance: getPtr(0)}
|
||||
mode := consts.TCefFileDialogMode(getVal(1))
|
||||
mode := consts.FileDialogMode(getVal(1))
|
||||
title := api.GoStr(getVal(2))
|
||||
defaultFilePath := api.GoStr(getVal(3))
|
||||
acceptFiltersList := lcl.AsStrings(getVal(4))
|
||||
callback := &ICefFileDialogCallback{instance: getPtr(5)}
|
||||
result := (*bool)(getPtr(6))
|
||||
var acceptFilters []string
|
||||
if acceptFiltersList.IsValid() {
|
||||
count := int(acceptFiltersList.Count())
|
||||
acceptFilters = make([]string, count, count)
|
||||
for i := 0; i < count; i++ {
|
||||
acceptFilters[i] = acceptFiltersList.Strings(int32(i))
|
||||
}
|
||||
acceptFiltersList.Free()
|
||||
}
|
||||
*result = fn.(onFileDialog)(browse, mode, title, defaultFilePath, acceptFilters, callback)
|
||||
*result = fn.(onFileDialog)(browse, mode, title, defaultFilePath, acceptFiltersList, callback)
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
@ -42,9 +42,11 @@ func (m *ICefFileDialogCallback) Cont(filePaths []string) {
|
||||
if !m.IsValid() {
|
||||
return
|
||||
}
|
||||
fps := lcl.NewStrings()
|
||||
for _, fp := range filePaths {
|
||||
fps.Add(fp)
|
||||
fps := lcl.NewStringList()
|
||||
if filePaths != nil {
|
||||
for _, fp := range filePaths {
|
||||
fps.Add(fp)
|
||||
}
|
||||
}
|
||||
imports.Proc(def.FileDialogCallback_Cont).Call(m.Instance(), fps.Instance())
|
||||
fps.Free()
|
||||
|
@ -1201,9 +1201,6 @@ const (
|
||||
// /include/internal/cef_types.h (cef_quick_menu_edit_state_flags_t)
|
||||
type TCefQuickMenuEditStateFlags = types.Int32
|
||||
|
||||
// /include/internal/cef_types.h (cef_file_dialog_mode_t)
|
||||
type TCefFileDialogMode = types.Cardinal
|
||||
|
||||
// /include/internal/cef_types.h (cef_log_severity_t)
|
||||
type TCefLogSeverity = types.Cardinal
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user