NSTextView not responding in an app without dock icon - objective-c

I have a menulet app with an NSTextView in it. I don't want the app to appear in the dock, so I wrote
<key>LSUIElement</key>
<true/>
in the Info.plist file.
But if this option is enabled, somehow an NSTextView in the menu stops responding at all.
How can I make it respond again? Maybe there are any other ways to hide the dock icon?
Thank you!
IMPORTANT UPDATE: This bug has been spotted only on Mac OS 10.6 and higher

The documentation states that keyboard events are not supported in views that are attached to a menu item (see Application Menu and Pop-up List Programming Topics).
That said, I had no problem creating a minimal sample app without Dock icon and a text view embedded in a status item's menu, so your problem is likely somewhere else. You can download my sample app here.

Related

Continuity camera contextual menu issue

The contextual menu in one NSTextView in my app does work and imports a sketch made on my iPad / iPhone.
My problem is that when another of my app's windows is visible, the contextual menu in its NSTextView does not connect to the iOS device.
Also, when this second window is visible, the menu no longer works in the other window.
I posted a screen recording to YouTube here: https://youtu.be/qWMUGdL7O8g
I tried changing firstresponder to no avail.

FinderSync issues with sidebar icon, toolbar icon and context menu

I am developing a mac app that must provide support for FinderSync application extension. Everything works fine, except some sidebar and toolbar icon issues.
Is there a way to programatically add the toolbar and sidebar icons without user intervention?
As from documentation, I didn't find anything to help me do that. They refer to these icons, by mentioning that the user must manually drag the folder manually to sidebar, or manually customize the toolbar, but not API to achieving this at runtime.
However there are apps that add themselves back if someone removes them from the toolbar.
Is there other way to display an icon for my folder, except iconset? I noticed that there are other apps out there which do have an icon in the sidebar, but they do not seem to have an icon set in bundle resources and the CFBundleIconFile is set to an icns resource.
Is there a way to disable a menu item in menuForMenuKind: ? In a normal NSMenu situation, the menu item should have no action or target, but this is not the case. Even if I do so, menu item is still enabled.
Thanks a lot for your help!
Welcome to the world of pain.
I've been developing Finder Sync extension as well, so here are answers to your questions:
Now I'm searching for the way to add programmatically Toolbar button, I saw some phrases that this can be done.
To add item to sidebar, you should use some LSSharedFileList code:
Add Item to Finder Sidebar
Via the same API you can check if your item is present in the sidebar, and do not add the duplicate.
Now (since Mac OS X 10.11) sidebar icon can be changed only via iconset. Previously it was possible to change it via Finder code injection, which is not allowed in 10.11.
Just use [menuItem setEnabled:NO]. Also please note that not all menu stuff is available in 10.10 - for instance, checkboxes are not shown and separator item is shown as space. Also, sender parameter in your handlers is always empty NSMenuItem object.

Menubar App: Desktop Switch Bug

I have build a cocoa mac application which is a menubar app. When you click it, it opens a NSWindow.
The problem:
1. When I open the menubar app on Desktop1.
2. Then go to Desktop2 and open the app by clicking the menubar icon, the app opens, but the desktop moves back to Desktop1 !
It's a rather tricky thing.
I appreciate your help !
Thanks
Try setting your window collection behavior to NSWindowCollectionBehaviorCanJoinAllSpaces so that, well, it isn't restrained to a single desktop.
[newWindow setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
NSWindowCollectionBehaviorMoveToActiveSpace should also work, but is a little more finicky.

Graphics error with NSStatusItem

My application uses NSStatusItem to be visible to the user.
So I set 'Application is agent (UIElement)' to YES, which basically hides the menu bar of the application, and hides the icon from the dock.
Now, I didn't delete the menu bar, so I can still react to shortcuts like cmd+W to close the preference window, or cmd+q to quit the application. The problem is, that anytime I use such a command, the menubar get's messed up.
I've noticed that other Apps which run in the background, like Growl 2, have the same issue.
I have no idea how to fix this.
Hopefully someone of you can help me
I'm running Mountain Lion.
thanks!
HINT
It probably has something to do with the 10.8 SKD. I have never noticed this issue before in any application.
How about move the whole Window menu to be Application menu submenu and then hide it?
You will still receive shortcuts and the highlited menu will be the application menu that is by anyway there (i suppose so, how else you will open preferences window? also shortcut?).

Use LSUIElement (aka no Dock icon) but retain the "File, Edit, View" menubar?

I want my app to have:
Menubar extra icon (by the clock)
App Menubar ("File, Edit, View, Etc")
I do not want my app to have:
Dock Icon
Is this possible? I am deploying for 10.6 and 10.7 via the Mac App Store if that matters.
Setting LSUIElement in the info.plist file removes the dock icon, but it also removes the menubar.
NSApplication's setActivationPolicy might be what you are after.
[NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory];
Please note the discussion:
Currently, NSApplicationActivationPolicyNone and
NSApplicationActivationPolicyAccessory may be changed to
NSApplicationActivationPolicyRegular, but other modifications are not
supported.Needs links to running application
As per NSApplicationActivationPolicyAccessory's documentation you may need to programmatically ensure that the menu bar appears.
You could create two "separate" applications. One that has a dock icon and menu items,the other one has just the icon by the clock.
When you click on the icon by the clock it launches the dock application. When you close the dock application the 'background' application stays running.
If that model will work for you then that's the way to go. But I would weigh that effort against what File-Edit-View will do for you.