mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
[V3/macos] Fix systray click handling when no attached window (#3207)
* Fix systray click handling * Open Menu if no window is attached in defaultClickHandler() * Remove systemTraySetMenu function * Fix a crash in hide-window example * Update changelog
This commit is contained in:
@@ -266,6 +266,7 @@ func (s *SystemTray) WindowDebounce(debounce time.Duration) *SystemTray {
|
||||
|
||||
func (s *SystemTray) defaultClickHandler() {
|
||||
if s.attachedWindow.Window == nil {
|
||||
s.OpenMenu()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -142,14 +142,7 @@ func (s *macosSystemTray) run() {
|
||||
s.menu.Update()
|
||||
// Convert impl to macosMenu object
|
||||
s.nsMenu = (s.menu.impl).(*macosMenu).nsMenu
|
||||
// We only set the tray menu if we don't have an attached
|
||||
// window. If we do, then we manually operate the menu using
|
||||
// the right mouse button
|
||||
if s.parent.attachedWindow.Window == nil {
|
||||
C.systemTraySetMenu(s.nsStatusItem, s.nsMenu)
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ void* createAttributedString(char *title, char *FG, char *BG);
|
||||
void* appendAttributedString(void* original, char* label, char* fg, char* bg);
|
||||
NSImage* imageFromBytes(const unsigned char *bytes, int length);
|
||||
void systemTraySetIcon(void* nsStatusItem, void* nsImage, int position, bool isTemplate);
|
||||
void systemTraySetMenu(void* nsStatusItem, void* nsMenu);
|
||||
void systemTrayDestroy(void* nsStatusItem);
|
||||
void showMenu(void* nsStatusItem, void *nsMenu);
|
||||
void systemTrayGetBounds(void* nsStatusItem, NSRect *rect);
|
||||
|
||||
@@ -130,16 +130,6 @@ void systemTraySetIcon(void* nsStatusItem, void* nsImage, int position, bool isT
|
||||
});
|
||||
}
|
||||
|
||||
// Add menu to system tray
|
||||
void systemTraySetMenu(void* nsStatusItem, void* nsMenu) {
|
||||
// Set the menu on the main thread
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
NSStatusItem *statusItem = (NSStatusItem *)nsStatusItem;
|
||||
NSMenu *menu = (NSMenu *)nsMenu;
|
||||
statusItem.menu = menu;
|
||||
});
|
||||
}
|
||||
|
||||
// Destroy system tray
|
||||
void systemTrayDestroy(void* nsStatusItem) {
|
||||
// Remove the status item from the status bar and its associated menu
|
||||
|
||||
Reference in New Issue
Block a user