How to open any built-in app through application - macos

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.

Related

XCode: debugging mac app window is always on top across applications

I am developing an Mac OS app, and have preference window presented as model. This works just fine as I want and I don't want to change that behaviour. The problem is: when the window is shown, and I debug on some breakpoints, the preference window is still there, however, Xcode's app is in focused now, but the preference window from the current app still shows on top. This is annoying. I have to drag it to somewhere to see the Xcode window. Is there anything that I can do so that if the app is in debug mode, then that preference window should also be gone away with my app in background and just Xcode is in foreground?
When a window is run as a modal window, its window level is set to NSModalPanelWindowLevel, which is above normal windows. As a hack just for debugging, you could do something like this just before running the window as modal:
dispatch_async(dispatch_get_main_queue(), ^{
NSApp.modalWindow.level = NSNormalWindowLevel;
});
Another approach would be to just run your app on a separate desktop space from Xcode.

OS X run system application with GUI over all others including fullscreen apps

I'm trying to write an accessibility app based on a "no-click" mouse concept. The idea is to capture mouse gestures that will be interpreted as clicks and pass the events to other apps. I have most of it working, except that I don't know how I could run it on top of fullscreen apps post Lion. Right now the app window is transparent and follows the mouse around, but this approach won't work with other "Desktops" or full screen apps, as the app stays in its current desktop when switching.
Any ideas?
What I needed was to call
[self setCollectionBehavior: NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorFullScreenAuxiliary];
and also (important for the fullscreen apps!) set Application is agent (UIElement) to true in the info.plist file.

On OSX, how can I ensure that a command-line application shows up in the application switcher once it creates a window?

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.

Mac fullscreen non-one visible application window

I have a cocoa fullscreen application and I also need to show on the same screen another's application window. Is it possible to run from my app a separate process with visible window on fullscreen? May be special tricks/hooks?
In the fullscreen mode, you can only show a single window of a single application. This system is very strict.

Accept mouse clicks without activating the application?

I am working on a utility application that controls other running applications. On certain input event my application displays a window, user can pick some operation from the window, the window disappears and control returns to the previous app. My problem is that clicking in my app’s window activates my application, thus removing focus from the previous application’s window. I can re-activate the previous application when my window closes, but I’d rather keep the original application activated all the time. Is that possible?
It's quite easy to to, just make your window an instance of NSPanel (a subclass of NSWindow), and set it as non-activating in Xcode/IB (or create it programatically, with NSNonactivatingPanelMask in the style mask).
One idea would be: while your app is running, try to keept track of the active window in the system.
After you activate your app and click the command button, restore the previous active window.
This is only an idea, I don't know how to do it on mac.

Resources