aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--example/main.go1
-rw-r--r--systray.go5
-rw-r--r--systray.h1
-rw-r--r--systray_darwin.m9
-rw-r--r--systray_nonwindows.go4
6 files changed, 21 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 81f16eb..ae7e06b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@ Debug
dll/systray_unsigned.dll
out.txt
.vs
+on_exit*.txt
diff --git a/example/main.go b/example/main.go
index 1c4b749..f889b3c 100644
--- a/example/main.go
+++ b/example/main.go
@@ -44,6 +44,7 @@ func onReady() {
systray.AddMenuItem("Ignored", "Ignored")
mUrl := systray.AddMenuItem("Open Lantern.org", "my home")
mQuit := systray.AddMenuItem("退出", "Quit the whole app")
+ systray.AddSeparator()
mToggle := systray.AddMenuItem("Toggle", "Toggle the Quit button")
shown := true
for {
diff --git a/systray.go b/systray.go
index 7fc72df..7b054dc 100644
--- a/systray.go
+++ b/systray.go
@@ -100,6 +100,11 @@ func AddMenuItem(title string, tooltip string) *MenuItem {
return item
}
+// AddSeparator adds a separator bar to the menu
+func AddSeparator() {
+ addSeparator()
+}
+
// SetTitle set the text to display on a menu item
func (item *MenuItem) SetTitle(title string) {
item.title = title
diff --git a/systray.h b/systray.h
index ef91c07..ad4b180 100644
--- a/systray.h
+++ b/systray.h
@@ -7,6 +7,7 @@ void setIcon(const char* iconBytes, int length);
void setTitle(char* title);
void setTooltip(char* tooltip);
void add_or_update_menu_item(int menuId, char* title, char* tooltip, short disabled, short checked);
+void add_separator();
void hide_menu_item(int menuId);
void show_menu_item(int menuId);
void quit();
diff --git a/systray_darwin.m b/systray_darwin.m
index 3a28c73..f7f3028 100644
--- a/systray_darwin.m
+++ b/systray_darwin.m
@@ -108,6 +108,11 @@
}
}
+- (void) add_separator:id
+{
+ [menu addItem: [NSMenuItem separatorItem]];
+}
+
- (void) hide_menu_item:(NSNumber*) menuId
{
NSMenuItem* menuItem;
@@ -178,6 +183,10 @@ void add_or_update_menu_item(int menuId, char* title, char* tooltip, short disab
runInMainThread(@selector(add_or_update_menu_item:), (id)item);
}
+void add_separator() {
+ runInMainThread(@selector(add_separator:), NULL);
+}
+
void hide_menu_item(int menuId) {
NSNumber *mId = [NSNumber numberWithInt:menuId];
runInMainThread(@selector(hide_menu_item:), (id)mId);
diff --git a/systray_nonwindows.go b/systray_nonwindows.go
index d3d42f3..40dc7be 100644
--- a/systray_nonwindows.go
+++ b/systray_nonwindows.go
@@ -60,6 +60,10 @@ func addOrUpdateMenuItem(item *MenuItem) {
)
}
+func addSeparator() {
+ C.add_separator()
+}
+
func hideMenuItem(item *MenuItem) {
C.hide_menu_item(
C.int(item.id),