NSStatusBar hidden in Mac OS X Lion - cocoa

I'm currently developing a status bar application. It's quite important to know if the status bar is hidden because an application entered the full screen mode. Is there a way to know that?
Thanks in advance.

Pretty much the only notification you're going to get is from NSWorkspaceActiveSpaceDidChangeNotification. Besides that, NSRunningApplication might be of a little help but you can't immediately distinguish if an app is in fullscreen because (on the user-end), an app's fullscreen mode is handled entirely by the Dock app.

Related

how to get the top window under mouse in mac

I want to develop a screen shot tool in mac,I need to get the top window under my mouse.
There is "ChildWindowFromPointEx" API in Windows OS, but Mac is more complex.
Does anybody know how to deal with it? Thanks very much
windowNumber returns the number of the frontmost window that would be hit by a mouse-down at the specified screen location. According to the apple docs.

Completely hide Dock in OS X via the terminal

Is there a way of doing this?
I want to hide the Dock when my JFrame starts and then show it when the JFrame is disposed.
According to this stackoverflow answer
There's is no API to control the Dock... at best, you can only suggest a tile to represent your app when present on the Dock.
To my recollection, you can hide the Dock from an App (and/or the MenuBar) but this is achieved from the Info.plist file (and Terminal applications do not have one) or you can do this with NSApplication, but once again Terminal apps do not have such object.
However, you may want to transform your CLI application into a faceless GUI application, so you can benefit from a GUI application without ever displaying anything.

NSWindow and Fullscreen

I am implementing a Cocoa application which supports the fullscreen mode. If the user quits while working on the fullscreen mode, I need to start the application in fullscreen mode,
While starting the application I check whether the application should start in fullscreen mode then call the toggleFullScreen: on NSWindow. Then the, application goes to the fullscreen mode and comes back to the normal window mode.
User can go to the full screen mode while working without any problem. Any tips on what's going wrong on this?
Make sure you really want to do this. Since Lion, there is a window restoration API that you should be using. See Any NSWindowRestoration examples? for how to use it. The caveat is that if "Close windows when quitting an application" in System Preferences is checked (which it is checked by default since 10.8), the window can only be restored upon reboot if the user chooses to do so.
If the user did not opt in for the window restoration setting throughout the OS across quitting applications, then generally you do not have to expect the window of your app to be restored for them. However, if you think you have a good reason otherwise, then I suggest invoking toggleFullScreen: after windowDidLoad: is called. I can only guess that you're calling it too soon and the window autosave might get in the way. It'd be helpful if you showed the relevant code.
Regardless, you should be implementing window restoration anyway and in the case of the window being restored by the API, you simply don't do anything.

Keyboard in a fullscreen cocoa app

Following up on this ( Display System Keyboard Mac application? ) question, the keyboard is coming up fine, but if my application is in fullscreen mode, the keyboard launches, but remains in the background. How do I get around this? Any help is much appreciated!
Thanks,
Teja
Full screen is, by definition, above other windows and elements. I don't know how well this would work, but you could try asking the view for its -window, then using -setLevel: to lower the window level. Unfortunately, assuming it works at all, this would probably allow other elements (like the dock or other floating panels above your full screen view as well.

bring the application from in focus, by clicking the icon of corresponding application

I was surprised this doesn't happen automatically, but I would like my applications window to be in focus as I click its dock icon, when in minimized mode.
Just to clarify, when I minimize the app, the window goes to dock, but when I click the its corresponding Dock Icon, the window don't come in focus.
Is there anything I am missing?
I am using Qt 4.5.3 on Mac OS X 10.5, 10.6
Thanks for help.
Rahul
First answer: That's the expected behavior of a Mac app. Try Safari for example. An app can be active without showing any window. In that case, only the menu bar at the top shows that the active app is changed. So, unless absolutely necessary, you shouldn't bring the minimized window back unless the user explicitly does so. That's the Mac way!
Second answer: I understand that there are cases where you want to bring the minimized window up. In Cocoa, the application delegate method -applicationDidBicomeActive is called when the application gets the focus, and there you can bring the window up yourself. I'm sure Qt also has a similar event/callback/signal or whatever, but I don't know any Qt ... :p Sorry I can't be of any help.

Resources