diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | example/main.go | 1 | ||||
| -rw-r--r-- | systray.go | 5 | ||||
| -rw-r--r-- | systray.h | 1 | ||||
| -rw-r--r-- | systray_darwin.m | 9 | ||||
| -rw-r--r-- | systray_nonwindows.go | 4 | 
6 files changed, 21 insertions, 0 deletions
| @@ -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 { @@ -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 @@ -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), | 
