Re: Auxiliary background executable without dock icon but with some UI
Re: Auxiliary background executable without dock icon but with some UI
- Subject: Re: Auxiliary background executable without dock icon but with some UI
- From: Jerry Krinock <email@hidden>
- Date: Sat, 25 Apr 2009 14:47:29 -0700
On 2009 Apr 25, at 01:52, Oleg Krupnov wrote:
In my app's bundle I have two executables - the main one and an
auxiliary one, launched by the main executable....
Now I want to use the aux executable additionally to show some UI
window.
I added the corresponding function to the vended object interface, but
the result is not satisfactory.
I've read a little about Distributed Objects but don't understand what
you mean by that.
The problem #1 is that although the desired UI window appears, it does
not accept mouse and keyboard input. I guess I haven't properly set up
the run loop, or window server, but I don't know how to do this for
such an auxiliary executable. Any hints would be welcome!
Well, since your run loop is running, I don't believe that is the
problem. As far as the window server, I've never had to set one up.
The system takes care of this and if there is such an API, it probably
wouldn't be much fun to use.
To show a window from a background process you should use
CFUserNotificationDisplayAlert(). (No, there is no Cocoa
equivalent.) The UI widgets available in this function are quite
limited. But I believe that if you require more, since you know how
to use Distributed Objects, you could message your main app to show
the window and then retrieve the user's reply.
The problem #2 is that another application icon (the same as the main
app's) appears in the dock, and begins jumping.
This may be due to a bug in Launch Services. Read this thread:
http://www.cocoabuilder.com/archive/message/cocoa/2009/3/26/233141
I worked around the bug I found by using Jim Correia's suggestion,
putting my auxiliary executable in Contents/Helpers instead of
Contents/MacOS.
How do I provide another Info.plist file for the auxiliary
executable in the same bundle?
I may be wrong, but I don't believe you can do that.
Below, I've pasted in a little category which makes using Contents/
Helpers for auxiliary executables a little more handy.
-----
#import <Cocoa/Cocoa.h>
/*!
@brief Provides support for finding helper tools in
a bundle's Contents/Helpers/
@details You can add a Copy Files Build Phase in Xcode for putting
things
in Contents/Helpers by setting the Destination popup to 'Wrapper'
and then
below that giving path "Contents/Helpers".
The reason why you'd want to put helper tools in
Contents/Helpers is explained in
http://www.cocoabuilder.com/archive/message/cocoa/2009/3/26/233141
*/
@interface NSBundle (HelperPaths)
/*
@brief Returns a path for a given tool name in the receiving bundle
in directory Contents/Helpers/
*/
- (NSString*)pathForHelper:(NSString*)helperName ;
@end
------
#import "NSBundle+HelperPaths.h"
@implementation NSBundle (HelperPaths)
- (NSString*)pathForHelper:(NSString*)helperName {
NSString* bundlePath = [self bundlePath] ;
NSString* path = [[bundlePath
stringByAppendingPathComponent:@"Contents"]
stringByAppendingPathComponent:@"Helpers"] ;
return path ;
}
@end
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden