Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
energye
energy
提交
71e0865b
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 搜索 >>
提交
71e0865b
编写于
1月 24, 2023
作者:
yanghye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
v2.3.55 add new sys tray
上级
baa61ac9
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
68 addition
and
28 deletion
+68
-28
cef/cef-sys-menu.go
cef/cef-sys-menu.go
+32
-0
cef/cef-tray-commponent.go
cef/cef-tray-commponent.go
+31
-23
cef/cef-tray-lcl-commponent.go
cef/cef-tray-lcl-commponent.go
+4
-0
cef/cef-tray-sys-commponent.go
cef/cef-tray-sys-commponent.go
+0
-4
example/dev-test/sys-tray/sys-tray.go
example/dev-test/sys-tray/sys-tray.go
+1
-1
未找到文件。
cef/cef-sys-menu.go
0 → 100644
浏览文件 @
71e0865b
package
cef
type
SysMenu
struct
{
Label
string
Items
[]
*
SysMenuItem
}
type
SysMenuItem
struct
{
ChildMenu
*
SysMenu
IsSeparator
bool
Label
string
Action
func
()
Disabled
bool
Checked
bool
Icon
[]
byte
Shortcut
string
}
// NewMenu 创建一个新菜单,给定指定的标签和要显示的项目列表
func
NewMenu
(
label
string
,
items
...*
SysMenuItem
)
*
SysMenu
{
return
&
SysMenu
{
Label
:
label
,
Items
:
items
}
}
// NewMenuItem 根据传递的标签和操作参数创建一个新菜单项
func
NewMenuItem
(
label
string
,
action
func
())
*
SysMenuItem
{
return
&
SysMenuItem
{
Label
:
label
,
Action
:
action
}
}
// NewMenuItemSeparator 创建将用作分隔符的菜单项
func
NewMenuItemSeparator
()
*
SysMenuItem
{
return
&
SysMenuItem
{
IsSeparator
:
true
}
}
cef/cef-tray-commponent.go
浏览文件 @
71e0865b
...
...
@@ -13,41 +13,44 @@ import (
"github.com/energye/golcl/lcl/types"
)
//TMouseEvent 鼠标事件
type
TMouseEvent
func
(
sender
lcl
.
IObject
,
button
types
.
TMouseButton
,
shift
types
.
TShiftState
,
x
,
y
int32
)
bool
//TrayICONClick 托盘图标鼠标事件
type
TrayICONClick
func
()
//ITray 托盘接口
type
ITray
interface
{
SetTitle
(
title
string
)
//设置标题
SetVisible
(
v
bool
)
//显示和隐藏托盘图标
Visible
()
bool
//
Show
()
//显示托盘菜单窗口 windows有效
Hide
()
//隐藏托盘菜单窗口 windows有效
close
()
//关闭托盘菜单窗口 windows有效
SetOnDblClick
(
fn
TrayICONClick
)
//双击事件 linux 和 macos 可能不启作用
SetOnClick
(
fn
TrayICONClick
)
//单击事件
SetOnMouseUp
(
fn
TMouseEvent
)
//up事件 linux 和 macos 可能不启作用
SetOnMouseDown
(
fn
lcl
.
TMouseEvent
)
//down事件 linux 和 macos 可能不启作用
SetOnMouseMove
(
fn
lcl
.
TMouseMoveEvent
)
//move事件 linux 和 macos 可能不启作用
SetIconFS
(
iconResourcePath
string
)
//设置托盘图标
SetIcon
(
iconResourcePath
string
)
//设置托盘图标
SetHint
(
value
string
)
//设置托盘hint(鼠标移动到托盘图标显示的文字)
ShowBalloon
()
//显示托盘气泡
SetBalloon
(
title
,
content
string
,
timeout
int32
)
ITray
//设置托盘气泡内容
Tray
()
ITray
//
获得 LCLTray, ( CefTray 返回 nil )
AsViewsFrameTray
()
*
ViewsFrameTray
//
AsCEFTray
()
*
CEFTray
//
AsLCLTray
()
*
LCLTray
//
SetTitle
(
title
string
)
//
SetTitle
设置标题
SetVisible
(
v
bool
)
//
SetVisible 设置
显示和隐藏托盘图标
Visible
()
bool
//
Visible 托盘的显示和隐藏状态
Show
()
//
Show
显示托盘菜单窗口 windows有效
Hide
()
//
Hide
隐藏托盘菜单窗口 windows有效
close
()
//
close
关闭托盘菜单窗口 windows有效
SetOnDblClick
(
fn
TrayICONClick
)
//
SetOnDblClick
双击事件 linux 和 macos 可能不启作用
SetOnClick
(
fn
TrayICONClick
)
//
SetOnClick
单击事件
SetOnMouseUp
(
fn
TMouseEvent
)
//
SetOnMouseUp
up事件 linux 和 macos 可能不启作用
SetOnMouseDown
(
fn
lcl
.
TMouseEvent
)
//
SetOnMouseDown
down事件 linux 和 macos 可能不启作用
SetOnMouseMove
(
fn
lcl
.
TMouseMoveEvent
)
//
SetOnMouseMove
move事件 linux 和 macos 可能不启作用
SetIconFS
(
iconResourcePath
string
)
//
SetIconFS
设置托盘图标
SetIcon
(
iconResourcePath
string
)
//
SetIcon
设置托盘图标
SetHint
(
value
string
)
//
SetHint
设置托盘hint(鼠标移动到托盘图标显示的文字)
ShowBalloon
()
//
ShowBalloon
显示托盘气泡
SetBalloon
(
title
,
content
string
,
timeout
int32
)
ITray
//
SetBalloon
设置托盘气泡内容
Tray
()
ITray
//
Tray 返回ITray接口
AsViewsFrameTray
()
*
ViewsFrameTray
//
AsViewsFrameTray 尝试转换为 views framework 组件托盘, 如果当前创建的是其它类型托盘返回nil
AsCEFTray
()
*
CEFTray
//
AsCEFTray 尝试转换为 LCL+CEF 组件托盘, 如果当前创建的是其它类型托盘返回nil
AsLCLTray
()
*
LCLTray
//
AsLCLTray 尝试转换为 LCL 组件托盘, 如果当前创建的是其它类型托盘返回nil
}
//LCL
系统
托盘
//LCL
Tray LCL
托盘
type
LCLTray
struct
{
owner
lcl
.
IComponent
trayIcon
*
lcl
.
TTrayIcon
popupMenu
*
lcl
.
TPopupMenu
}
//
CEF views framework 系统
托盘
//
ViewsFrameTray CEF views framework
托盘
type
ViewsFrameTray
struct
{
trayWindow
*
ViewsFrameworkBrowserWindow
trayIcon
*
lcl
.
TTrayIcon
...
...
@@ -56,7 +59,7 @@ type ViewsFrameTray struct {
isClosing
bool
}
//CEF + LCL 托盘
//CEF
Tray CEF
+ LCL 托盘
type
CEFTray
struct
{
*
lcl
.
TForm
owner
lcl
.
IComponent
...
...
@@ -68,3 +71,8 @@ type CEFTray struct {
isClosing
bool
url
string
}
//SysTray 系统原生托盘
type
SysTray
struct
{
trayStart
,
trayStop
func
()
}
cef/cef-tray-lcl-commponent.go
浏览文件 @
71e0865b
...
...
@@ -69,14 +69,17 @@ func (m *LCLTray) SetOnClick(fn TrayICONClick) {
fn
()
})
}
func
(
m
*
LCLTray
)
SetOnMouseUp
(
fn
TMouseEvent
)
{
m
.
trayIcon
.
SetOnMouseUp
(
func
(
sender
lcl
.
IObject
,
button
types
.
TMouseButton
,
shift
types
.
TShiftState
,
x
,
y
int32
)
{
fn
(
sender
,
button
,
shift
,
x
,
y
)
})
}
func
(
m
*
LCLTray
)
SetOnMouseDown
(
fn
lcl
.
TMouseEvent
)
{
m
.
trayIcon
.
SetOnMouseDown
(
fn
)
}
func
(
m
*
LCLTray
)
SetOnMouseMove
(
fn
lcl
.
TMouseMoveEvent
)
{
m
.
trayIcon
.
SetOnMouseMove
(
fn
)
}
...
...
@@ -104,6 +107,7 @@ func (m *LCLTray) SetHint(value string) {
m
.
trayIcon
.
SetHint
(
value
)
}
//SetTitle 设置标题
func
(
m
*
LCLTray
)
SetTitle
(
title
string
)
{
m
.
trayIcon
.
SetHint
(
title
)
}
...
...
cef/cef-tray-sys-commponent.go
浏览文件 @
71e0865b
...
...
@@ -7,7 +7,3 @@
//----------------------------------------
package
cef
//Sys 系统托盘
type
SysTray
struct
{
}
example/dev-test/sys-tray/sys-tray.go
浏览文件 @
71e0865b
...
...
@@ -48,7 +48,7 @@ func onReady() {
fmt
.
Println
(
"systray.onReady"
)
systray
.
SetTemplateIcon
(
icon
.
Data
,
icon
.
Data
)
systray
.
SetTitle
(
"Energy Sys Tray"
)
systray
.
SetTooltip
(
"Energy tooltip"
)
systray
.
SetTooltip
(
"
这里是文字
\n
Energy tooltip"
)
systray
.
SetOnClick
(
func
()
{
fmt
.
Println
(
"SetOnClick"
)
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录