Menu closes during Drag and Drop with NSStatusItem - osx-mountain-lion

This question is in response to Drag and Drop with NSStatusItem
The code from #rob Keniger works for me. Following these exact steps, When I run the app, click the menu bar icon, I can drag things to my drag area and everything works. My problem is if I run the app, (then instead of clicking the menu icon first) click Finder, then click the menu bar icon, when I try to drag, the menu closes as I'm dragging.
How do I make the menu view stay open every time the user has the menu open and is dragging?

Looks like you have to do this:
[NSApp activateIgnoringOtherApps:YES];

Related

Swift - NSMenu closes when clicking outside of menu

so i have a simple NSMenu. It is attached to a Status Item Button.
When i click the Button it pops Open.
Now my Problem is that as soon as i click outside of the NSMenu, it closes. How can i avoid that ?
I did try many things but cant get that to work.
The reason i need that is that when the user clicks something in the NSMenu, another window opens, and while this window is open i also want the NSMenu to stay open. But it just does not work.
I feel like its impossible.
Many Thanks in advance.
I believe you have to create a custom view that pops up but something that could be done natively with just NSMenu.

Opening New Window using Menu Tab cocoa application

I am new to Mac os x and am having some difficulties with the the transition from windows and widgets. In my MainMenu.xib, I have the main window of my app, call it window A, and I added a menu tab to the main menu tabs as well as a new window B to the MainMenu.xib. When I launch my app, I want window A to open (which it does) and then when the user clicks the new menu tab, I want window B to appear. Is there an easy to way to connect the menu tab to window B in the IB so that it opens when the menu tab is clicked?
Thanks for your help
What are main menu tabs?
To show Window B call [myWindowB makeKeyAndOrderFront:sender].
For window B , uncheck visible at lunch from interface builder(window attribute). when the user clicks the new menu tab.
[WindowA orderOut:sender];
[WindowB makeKeyAndOrderFront:sender];
write this code.

How to make action to close NSPopover?

Hi I implemented an NSPopover in one of my apps, but the popover will not close. I'm guessing that it should close once I click something else, but its not. I know that there's a close popover action but that only works for a different button. How can I make it look to see that the popover is open and when it is open to close the popover when I press the same button?
I solved the problem!
First go ahead and click your .xib file.
Where you see the first responder box and files owner - click on the popover.
On the sidebar go to the attributes center
Change the behavior from Application-Defined to Transient and it should work!
That should make the popover disappear once someone has clicked outside the popover.
Another way to close the popover is to have a separate button.
Just add another NSButton and then link it to the popover on the sidebar and set it to Received actions -> perform close:

update statusbar menu on click mac os x cocoa

I've been playing around with a statusbar menu app and what I'd like it to do is to update the content of the menu when it is clicked. I've been able to get everything working on the awakefromnib function and it works as expected. Now i just want to update the menu everytime I click on the status bar. This surely can be done, since it's done in the dropbox statusbar menu and many of the native app statusbar menus. I'm not able to associate a action directly with the click of the menu and I don't want to leave a loop running in the background cause I don't really see a need for it. Any ideas? An alternative would be to have an action associated to a menu item which does not cause the menu to get hidden again. Any help would be welcome.
Just set a delegate for your menu, and implement the -(void)menuWillOpen:(NSMenu *)menu method.

Hiding NSMenu while the dock remains active

I want my app to show his menu on launch only if the user didn't open a file. Now I can't seem to make it work. Hiding the menu makes the dock and the status bar invisible. I want them to still be there, but not with my own menu (e.g. if you open a file from finder, the finder menu is still visible, but my app opens a window that handles the file, and quits if the user cancels or on completion).
I probably didn't explain it well enough, but here's what I did to solve it :
Add this line to the plist of my app (this produces an app without dock icon or menu), the dock and the menu bar will still be there, but won't be changed by the app :
LSUIElement
(And set the checkbox to true).
This makes your app UI-only (it doesn't show his NSMenu nor does it add an icon to the dock, but just shows your GUI.

Resources