I've been trying to solve this for a few days now, but keep on hitting brick walls.
All I want to do is create a new menu popup with a dark apperance on the screen.
`popUpMenuPositioningItem:atLocation:inView:` works great, except you can't give it a dark apperance.
My workaround to that is creating an invisible `NSWindow`, and passing along the windows `contentView` to `popUpMenuPositioningItem`.
Frustratingly, whilst this works great on whichever screen has the macOS menu bar (as per the "Arrangement" tab of the "Displays" Sytem Preferences), the menu never pops up on secondary screens for some reason.
I've also tried using `popUpContextMenu` and creating a fake `NSEvent`, but it suffers from the same problems.
Interestingly, if I move my app to a secondary screen, then trigger `popUpMenuPositioningItem` or `popUpContextMenu` twice in succession, the popup will appear if you click the desktop (i.e. the first popup call must be appearing but not visible, as performing a `popUp` is a blocking function - but when you click the desktop, that must close the original popup, even though it's not visible, and successfully show the second popup call).
Here's my test code:
NSMenu *menu = [[NSMenu alloc] initWithTitle:@"Contextual Menu"];
[menu insertItemWithTitle:@"Beep" action:nil keyEquivalent:@"" atIndex:0];
[menu insertItemWithTitle:@"Honk" action:nil keyEquivalent:@"" atIndex:1];
NSPoint menuPoint = [NSEvent mouseLocation];
NSRect contentRect = NSMakeRect(menuPoint.x, menuPoint.y, 0, 0) ;
NSWindow *tmpWindow = [[NSWindow alloc] initWithContentRect:contentRect
styleMask:0
backing:NSBackingStoreBuffered
defer:NO] ;
tmpWindow.releasedWhenClosed = NO ;
tmpWindow.appearance = [NSAppearance appearanceNamed:NSAppearanceNameVibrantDark] ;
[tmpWindow orderFront:nil] ;
[menu popUpMenuPositioningItem:nil atLocation:NSMakePoint(0, 0) inView:tmpWindow.contentView] ;
[tmpWindow close] ;I've tried lots of different things, which you can see in this GitHub thread: https://github.com/Hammerspoon/hammerspoon/pull/1874
Any help you could provide would be HUGELY appreciated, as I've been running around in circle for a few days now.
Thanks in advance!
Best Regards, Chris!