OSX Fullscreen API and Menu Bar - macos

When using the OSX FullScreen API, is there a way to detect whether the Menu Bar (or the Dock, for that matter) are currently being displayed over top of your application?
For example, a delegate which notifies the application when the Menu Bar animates in, and then sends another notification when the Menu Bar animates out?

NSMenu.menuBarVisible()
there's also NSMenuBarDelegate protocol which has menuWillOpen() and menuWillClose(). but so far I haven't gotten any luck with this one

Related

Make macOS window capture hover events even if set _setPreventsActivation:true and canBecomeKeyWindow:true

I want to achieve a certain window behavior for a macOS app. I subclassed NSWindow to be able to add additional properties. So far, it works well with almost all requirements (dragging it, clicking buttons) while preserving the core requirement of not making the currently active app losing focus. What does not work is making the window's UI elements react to mouse-hover events.
Requirements:
☑️ Don't activate the app when showing the window → _setPreventsActivation:true
☑️ Prevent activation of the app when interacting with the window (click/drag) → _setPreventsActivation:true
﹖Make the window react to mouse hover events over interactive UI elements without activating the app
An example of an application that does very much what I intend to do (UX-wise) is 1Password. Here is a short clip: An animated GIF showing 1Password UX
Can someone explain what they likely do to make their window behave this way?

Is there anyway to hide menubar items in MacOS?

I know I can "auto hide menu bar" in system preferences, however, what I like to do is hide items like this repository.
https://github.com/dwarvesf/hidden
This repository can hide items on right, but I wonder if I can hide left items (which are application menus).
Any idea is appreciated.
As for application menus on the left, those can't be hidden, I'm pretty sure.
Applications often have the option to enable or disable their menu bar helper app in the main preferences. If that doesn't help, e.g. if it's a full-fledged menu bar app, not just a helper, then to my knowledge the only solutions are Hidden Bar, which you mentioned, and Bartender.
I'm using the latter, and it does a very fine job. You have four options in Bartender's preferences:
Show (default macOS behavior)
Hide (menulet will be hidden in a special Bartender secondary menu bar, accessible via the triple-bullet icon ··· on the far right)
Always show (menulet will be visible in the main macOS menu bar as well as the secondary Bartender menu bar at the same screen position)
Always hide (menulet will be completely hidden)
Some older menulets seem to switch their position occasionally, e.g. after wake-from-sleep, and Bartender isn't yet able to fix the position of BitBar instances. But for the vast majority of menu bar apps and helpers it will work just fine.

How to create an arrow pointing to my app's icon on the menu bar?

I have a menu bar only application. On the first time the user runs the app I want to create an animated arrow pointing to my app's icon on the menu bar.
The first idea I had was to create a NSPopover showing the arrow but that is obtrusive per se because I don't think I can make the popover invisible at all. I just want to make an arrow moving up and down pointing to my app's icon on the menubar and that must be App Store compatible.
Is that possible? How?
You can create a borderless transparent window and set its level to screen saver and set it to ignore mouse clicks. Within this window you can draw your arrow, again use a transparent content view. Look up the docs on NSWindow, NSView etc. to construct this.
Alternatively you can change the menu bar icon of your app itself - switch it, highlight it, animate it. This is the typical way a menu bar app attracts attention. Look up NSStatusItem and NSStatusBarButton.
HTH

NSWindow, how not to be part of a screenshot?

My Cocoa app displays a transparent window on the screen, but when the user tries to take a screenshot using Mac OS X's built-in screen capture key with the option of selecting full windows (Command-Shift-4, then Space Bar), my window gets highlighted as part of the possible windows to capture.
How can I tell my Window or App not to allow this? My Window already refuses to be the Main Window or Key Window through -canBecomeKeyWindow and -canBecomeMainWindow both returning NO, but this still happens.
The Window is also at the NSModalPanelWindowLevel and NSScreenSaverWindowLevel does the same thing.
Notice that every window is eligible for screenshots, even the desktop, dock and menu bar, which are special windows. You can even take a screenshot of the Exposé overlay window itself. This leads me to believe that there is no way to do this.
I suppose you could hook the Command+Shift+4 key event and hide the window, but that key combo is user-definable, so it is subject to change.

Applescript access to last.fm app via application icon in menu bar

I want to create an Applescript to drive the last.fm player app. I'm trying to do this via last.fm application icon in the menu bar rather than using the main application menus, as this approach (I think) won't cause last.fm to switch to the foreground. The overall plan is to bind my script to a quicksilver trigger so I can stop|start|skip|love|ban|tag tracks from the keyboard.
My problem is I can't find what UI element to bind the applescript to. I've used UI Browser to scan through the UI object model but it draws a blank with the last.fm icon in the menu bar. Any thoughts appreciated.
Items in the menu bar are NSStatusItem and the part of the menu bar in which they live is an NSStatusBar. I suspect from past experience, though I am not sure, that if your applescript would have caused the main application to switch to the foreground, it will cause the menu bar item to switch to the foreground to the extent that it can, meaning that the application in the foreground will probably lose focus.

Resources