Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
energye
energy
提交
c2c7e75a
energy
项目概览
energye
/
energy
通知
13
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
energy
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c2c7e75a
编写于
7月 18, 2023
作者:
yanghye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
A: demo drag file
上级
c7ac9917
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
46 addition
and
88 deletion
+46
-88
example/dev-test/cefdialog/resources/enregy.png
example/dev-test/cefdialog/resources/enregy.png
+0
-0
example/dev-test/cefdialog/resources/index.html
example/dev-test/cefdialog/resources/index.html
+0
-88
example/drag-file/drag-file.go
example/drag-file/drag-file.go
+46
-0
example/drag-file/resources/icon.ico
example/drag-file/resources/icon.ico
+0
-0
example/drag-file/resources/icon.png
example/drag-file/resources/icon.png
+0
-0
未找到文件。
example/dev-test/cefdialog/resources/enregy.png
已删除
100644 → 0
浏览文件 @
c7ac9917
71.0 KB
example/dev-test/cefdialog/resources/index.html
已删除
100644 → 0
浏览文件 @
c7ac9917
<html>
<head>
<title>
Dialog Test
</title>
<script>
function
show_alert
()
{
alert
(
"
I am an alert box!
"
);
}
function
show_confirm
()
{
var
r
=
confirm
(
"
Press a button
"
);
var
msg
=
r
?
"
You pressed OK!
"
:
"
You pressed Cancel!
"
;
document
.
getElementById
(
'
cm
'
).
innerText
=
msg
;
}
function
show_prompt
()
{
var
name
=
prompt
(
"
Please enter your name
"
,
"
Harry Potter
"
);
if
(
name
!=
null
&&
name
!=
""
)
document
.
getElementById
(
'
pm
'
).
innerText
=
"
Hello
"
+
name
+
"
!
"
;
}
// window.onbeforeunload = function() {
// return 'This is an onbeforeunload message.';
// }
function
update_time
()
{
document
.
getElementById
(
'
time
'
).
innerText
=
new
Date
().
toLocaleString
();
}
function
setup
()
{
update_time
();
setInterval
(
update_time
,
1000
);
if
(
location
.
hostname
!=
'
tests
'
&&
location
.
hostname
!=
'
localhost
'
)
{
alert
(
'
Parts of this page can only be run from tests or localhost.
'
);
return
;
}
// Enable all elements.
var
elements
=
document
.
getElementById
(
"
form
"
).
elements
;
for
(
var
i
=
0
,
element
;
element
=
elements
[
i
++
];
)
{
element
.
disabled
=
false
;
}
}
function
show_file_dialog
(
element
,
test
)
{
var
message
=
'
DialogTest.
'
+
test
;
var
target
=
document
.
getElementById
(
element
);
// Results in a call to the OnQuery method in dialog_test.cpp
window
.
cefQuery
({
request
:
message
,
onSuccess
:
function
(
response
)
{
target
.
innerText
=
response
;
},
onFailure
:
function
(
error_code
,
error_message
)
{}
});
}
function
testRunFile
()
{
ipc
.
emit
(
"
testRunFile
"
);
}
//window.addEventListener('load', setup, false);
</script>
</head>
<body
bgcolor=
"white"
>
<form
id=
"form"
>
Click a button to show the associated dialog type.
<br/><input
type=
"button"
onclick=
"show_alert();"
value=
"Show Alert"
>
<br/><input
type=
"button"
onclick=
"show_confirm();"
value=
"Show Confirm"
>
<span
id=
"cm"
></span>
<br/><input
type=
"button"
onclick=
"show_prompt();"
value=
"Show Prompt"
>
<span
id=
"pm"
></span>
<br/>
input type="file" (.png):
<input
type=
"file"
name=
"pic"
accept=
".png"
>
<br/>
input type="file" (image/*):
<input
type=
"file"
name=
"pic"
accept=
"image/*"
>
<br/>
input type="file" (multiple types):
<input
type=
"file"
name=
"pic"
accept=
"text/*,.js,.css,image/*"
>
<br/>
input type="file" (directory):
<input
type=
"file"
webkitdirectory
accept=
"text/*,.js,.css,image/*"
>
<br/><input
type=
"button"
onclick=
"show_file_dialog('fop', 'FileOpenPng');"
value=
"Show File Open (.png)"
disabled=
"true"
>
<span
id=
"fop"
></span>
<br/><input
type=
"button"
onclick=
"show_file_dialog('foi', 'FileOpenImage');"
value=
"Show File Open (image/*)"
disabled=
"true"
>
<span
id=
"foi"
></span>
<br/><input
type=
"button"
onclick=
"show_file_dialog('fom', 'FileOpenMultiple');"
value=
"Show File Open (multiple types/files)"
disabled=
"true"
>
<span
id=
"fom"
></span>
<br/><input
type=
"button"
onclick=
"show_file_dialog('fof', 'FileOpenFolder');"
value=
"Show File Open Folder"
disabled=
"true"
>
<span
id=
"fof"
></span>
<br/><input
type=
"button"
onclick=
"show_file_dialog('fs', 'FileSave');"
value=
"Show File Save"
disabled=
"true"
>
<span
id=
"fs"
></span>
<p>
<button
onclick=
"testRunFile()"
>
testRunFile
</button>
</p>
<p
id=
"time"
></p>
</form>
</body>
</html>
example/d
ev-test/cefdialog/cefdialog
.go
→
example/d
rag-file/drag-file
.go
浏览文件 @
c2c7e75a
...
...
@@ -4,7 +4,7 @@ import (
"embed"
"fmt"
"github.com/energye/energy/v2/cef"
"github.com/energye/energy/v2/c
ef/ipc
"
"github.com/energye/energy/v2/c
ommon
"
"github.com/energye/energy/v2/consts"
"github.com/energye/energy/v2/pkgs/assetserve"
"github.com/energye/golcl/lcl"
...
...
@@ -14,9 +14,15 @@ import (
var
resources
embed
.
FS
func
main
()
{
cef
.
GlobalInit
(
nil
,
nil
)
cefApp
:=
cef
.
NewApplication
()
cef
.
BrowserWindow
.
Config
.
Url
=
"http://localhost:22022/index.html"
cef
.
GlobalInit
(
nil
,
&
resources
)
app
:=
cef
.
NewApplication
()
cef
.
BrowserWindow
.
Config
.
Url
=
"http://chrome.360.cn/html5_labs/demos/dnd/"
if
common
.
IsLinux
()
{
cef
.
BrowserWindow
.
Config
.
IconFS
=
"resources/icon.png"
}
else
{
cef
.
BrowserWindow
.
Config
.
IconFS
=
"resources/icon.ico"
}
cef
.
BrowserWindow
.
Config
.
Title
=
"ENERGY - Drag File"
cef
.
SetBrowserProcessStartAfterCallback
(
func
(
b
bool
)
{
fmt
.
Println
(
"主进程启动 创建一个内置http服务"
)
//通过内置http服务加载资源
...
...
@@ -27,20 +33,14 @@ func main() {
go
server
.
StartHttpServer
()
})
cef
.
BrowserWindow
.
SetBrowserInit
(
func
(
event
*
cef
.
BrowserEvent
,
window
cef
.
IBrowserWindow
)
{
//WindowTransparent(types.HWND(window.Handle()))
ipc
.
On
(
"testRunFile"
,
func
()
{
acceptFilters
:=
lcl
.
NewStringList
()
acceptFilters
.
Add
(
".png"
)
callback
:=
cef
.
RunFileDialogCallbackRef
.
New
()
callback
.
SetOnFileDialogDismissed
(
func
(
filePaths
*
lcl
.
TStrings
)
{
for
i
:=
0
;
i
<
int
(
filePaths
.
Count
());
i
++
{
path
:=
filePaths
.
Strings
(
int32
(
i
))
fmt
.
Println
(
path
)
}
})
window
.
Chromium
()
.
Browser
()
.
RunFileDialog
(
consts
.
FILE_DIALOG_SAVE
,
"打开窗口"
,
""
,
nil
,
callback
)
fmt
.
Println
(
"RunFileDialog end"
)
event
.
SetOnDragEnter
(
func
(
sender
lcl
.
IObject
,
browser
*
cef
.
ICefBrowser
,
dragData
*
cef
.
ICefDragData
,
mask
consts
.
TCefDragOperations
,
window
cef
.
IBrowserWindow
,
result
*
bool
)
{
if
mask
&
consts
.
DRAG_OPERATION_LINK
==
consts
.
DRAG_OPERATION_LINK
{
fmt
.
Println
(
"SetOnDragEnter"
,
mask
&
consts
.
DRAG_OPERATION_LINK
,
dragData
.
IsLink
(),
dragData
.
IsFile
(),
"GetFileName:"
,
dragData
.
GetFileName
(),
"GetFileNames:"
,
dragData
.
GetFileNames
())
*
result
=
false
}
else
{
*
result
=
true
}
})
})
cef
.
Run
(
cefA
pp
)
cef
.
Run
(
a
pp
)
}
example/drag-file/resources/icon.ico
0 → 100644
浏览文件 @
c2c7e75a
16.6 KB
example/drag-file/resources/icon.png
0 → 100644
浏览文件 @
c2c7e75a
3.9 KB
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录