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.
Related
When running a WebKitGTK+ application on macOS, every instance of the WebKitWebProcess makes a new dock icon. Is there a way to disable/fix this behavior?
Suggestions to use lsuielement (https://developer.apple.com/documentation/bundleresources/information_property_list/lsuielement) have not worked. It seems that WebKit itself and/or GTK is forcing each WebView widget to have a new application icon in the dock.
The Nyxt Browser folks worked this out with some help from WebKitGtk. You need to patch WebKitWebView so that it gets it NSApp and calls [NSApp setActivationPolicy: NSApplicationActivationPolicyProhibited].
Nyxt spread that over several patches and a naked file write in their MacPorts Portfile, I've consolidated it into a single patch for Gtk-OSX.
I'm working on a cross-platform command-line application (in C++ on
Win/Linux and ObjC++ on OSX) which sometimes creates an OpenGL
context. The OpenGL context and window creation code is obviously
different for the different platforms, but on OSX it's done through
NSOpenGLView and NSWindow. There's no nib, and it's not built with
Xcode (it uses a cross-platform build script).
On OSX, the window is created and works fine, but the OpenGL window
doesn't show up in the Application Switcher (Cmd-Tab). This means
that it's tricky to find the window if you 'lose it' behind other
windows, and can often only be found by going to Mission
Control/Expose.
My question is: is there a programmatic way (i.e. a message to send to
the NSWindow object or NSApplication) to ensure that a (unix-style)
command line application will show up in the Cmd-Tab list once the
window is created?
You need to transform the process from an accessory to a regular app. Call [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular].
Once you do that, though, the app will also have a menu bar when it's active. This is good because it's what users expect. However, you probably need to add appropriate items to the menus in that menu bar to get a decent user experience.
Your app will appear in the Dock as well as the Command-Tab application switcher. By default, an unbundled executable will get an icon that looks like a CRT display showing the word "exec". You can use [NSApp setApplicationIconImage:someImage] to set a better icon, although the Dock will revert to showing the generic executable icon briefly as the process exits.
my mac os application is running in full screen mode.
On button click i'm opening finder window which allow me to open any another file or application but problem is that, when i open any another app, screen switches back to xCode and that application opens. Need to open selected app/file above same window.
I have tried:
**[[NSWorkspace sharedWorkspace] launchApplication:path];**
passing application path to launchAppication method
How can i do this?????
Help
The issue is basically because using [NSView enterFullScreenMode:withOption:] will set the app's [NSWindow level] to kCGMaximumWindowLevel - 1, so that all other app's windows will appear behind it.
This is kinda what you would expect from a fullscreen app, which implies system-modal behaviour.
I guess the only way of allowing another app to appear in front of the fullscreen app would be to lower the window level, however I have no idea what effect that would have.
How to prevent a window to deminiaturizing when a user click on the dock tile of the window?
In one part of my application , I am miniaturizing the window and then have to ensure that user cannot deminiaturize it for a specified time .The application has more than one window.
Please suggest how to do this in cocoa.
This is against Apple's Human Interface Guidelines (see section 'Minimizing and Expanding Windows') and as a result there is almost certainly no way to do this.
You cannot. That is something the OS is doing and you can't influence it. You need to adapt your design so it's no problem if the user unhides the window.
I need to host my window upon a window of another application.
How to enumerate windows of another Cocoa application? Is it possible to control
them?
If no: how can I draw upon a window of another application?
Thanks!
How to enumerate windows of another Cocoa application?
You can enumerate the windows of another application using the Accessibility API. It doesn't matter whether that application is Cocoa or not.
Is it possible to control them?
Here, it does matter, indirectly, whether the application is Cocoa (or Carbon using standard controls). More precisely, it matters whether the application is accessible.
It usually is possible to move another window, resize it, or do simple things with controls in it (such as press buttons).
It is not possible to tape one of your windows to a window in another application. You will have to observe its location and move your window when the other moves. Following a live drag this way is not possible.
If no: how can I draw upon a window of another application?
You can't. You can only draw in your own windows.
You can make a transparent overlay window and draw on that, but that gets you back to the problem of taping one of your windows to a window in another application.
You should probably ask a broader question about whatever it is you hope to achieve by taping one of your windows to a window in another application or by drawing into a window in another application.
Checkout CGWindow.h
CGWindowListCreateDescriptionFromArray() is probably what you're looking for.
Cocoa does not support reparenting of another application window, or drawing on it.
But, there're two ways to get windows attributes for all the applications, like position, size, z-order, etc.
Accessibility API (also allows to control a foreign application window: move, resize, press buttons on it, etc.). If a foreign application does not support Accessibility API, then...
Quartz Window Services and a sample code for them, called "Son of Grab".