how to keep the dockMenu open when clicking items in cocoa app - swift

i have items in my dock menu that needs the dock menu to stay open
when the items are clicked
im refering to when u right click on an app and you get the dock menu
automaticly, it closes it
anyway to override this?

Related

Window NSMenu adding extra NSMesnuItems (Swift, macOS)

I deleted all the menu items from the Window NSMenu except Minimize and Bring All to Front. However, when I run the app, three more menu items get added: Move Window to Left Side of Screen, Move Window to Right Side of Screen and Enter Full Screen. How do I remove these menu items? Has it got something to do with the attribute inspector of my Window (just a guess)?
For reference:

is there a way to programaticly open/show the applicationDockMenu

is there a way to programaticly open/show the applicationDockMenu
this is the menu you get when you right click on an open app in the dock

close sidr menu when user clicks link

I'm developing a site that uses the sidr menu. This site also uses modal windows to display content. when a user presses a menu item and it opens a modal window, the window opens below the sidr menu.
should I:
A. stack the modal window above the slidr menu so the entire contents can be seen? This might work as the toggle menu button is covered.
B. Force the menu to close so the modal window is not closed.
I thought changing the z-index of the modal window would work but I can't get it to load above the menu. the z-index of the menu is 999999. I tried 1,000,000 for the modal window, but it still loads below the menu.
what else can I try?

How to display the main menu when Dock icon is hidden?

I developed a basic menubar app. How do you hide the dock icon and still have the Main Menu display when menubar app (status-item) is active?
Note: The Main Menu only displays If the dock icon is not hidden.
e.g. Main Menu (File, Edit, View etc at the left of the menu bar)

Menu Bar Popover Opens on Dock Icon Click OSX

I added a menu bar icon that opens a popover. It works ok but when I close the app via the red cross and try to open the app again with a click on the dock icon it opens the application window (as it should) but also the menu bar popover (which it should not). How can I only open the application window and not the popover when I click on the dock icon? My code that handles the opening of when clicking the dock icon looks like this:
func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
if !flag {
for window: AnyObject in sender.windows {
window.makeKeyAndOrderFront(self)
}
}
return true
}
I met this problem today too.
I had the same code so I tried to detect somehow if window is popover but failed.
Also I found that if you close main window after start and then click dock icon, if you print sender.windows, it shows 3 items (in my case): <NSStatusBarWindow: 0x101300110>, <NSStatusBarWindow: 0x101108800>, <NSWindow: 0x6080001e0400>and opens only main window, without popover, but if popover was opened once, then clicking on dock icon (when the main window is closed) causes show of both the main window and the popover. And print(window) in the for cycle now shows 4 items - the last is <_NSPopoverWindow: 0x1011284b0>.
And also I printed popover.isShown, and it says false even after the popover is opened by clicking the dock icon. I couldn't find a way to detect and ignore this particular window.
So the only way I found is to replace
for window: AnyObject in sender.windows {
window.makeKeyAndOrderFront(self)
}
with
sender.windows[2].makeKeyAndOrderFront(self)
because every time the main window appears on the third place
Hope there's a better way and someone will teach us.