Re: dispatch_sync(dispatch_get_main_queue() UI weirdness
On 9/6/14, 0:22, cocoa-dev-requ...@lists.apple.com wrote: > Date: Sat, 06 Sep 2014 06:18:41 +0800 > From: Roland King > To: Jens Alfke > Cc: Jonathan Guy , cocoa-dev@lists.apple.com > Subject: Re: dispatch_sync(dispatch_get_main_queue() UI weirdness > Message-ID: <1efd71f4-dd4d-4937-a238-348b3c81d...@rols.org> >> >> Why not? I assume Jonathan's -shouldIAccept: is running a nested >> event loop for the modal panel, since it doesn't return till the >> user dismisses it. >> >> (Whether it's a dispatch_sync or a dispatch_async doesn't matter; >> the main thread will be blocked for as long as the block takes to >> run.) >> >> I still think the problem is that you're blocking the >> dispatch-queue's thread for a long time. Try pausing the app while >> the dialog is up and looking at what the various threads are >> doing. Sidenote: on OS X the best way to run a UI-doing block would be to define this function: void RunBlockOnMainThread(^(void)block) { CFRunLoopPerformBlock([[NSRunLoop mainRunLoop] getCFRunLoop], kCFRunLoopCommonModes, block); } and call that whenever you want something to be performed on the main thread. But never do modal stuff in that block. So the original code would look like: - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { RunBlockOnMainThread (^{ // So my app is doing some background stuff // and I need a file from the user so // code blah blah code RunBlockOnMainThread(^{ NSOpenPanel *op = [NSOpenPanel openPanel]; [op beginWithCompletionHandler:^{ // handle the open panel results here }]; }); // resume code blah blah code <== probably move this into the results block? }); } HTH, -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." http://brockerhoff.net/blog/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: dispatch_sync(dispatch_get_main_queue() UI weirdness
On 9/6/14, 14:50, Ken Thomases wrote: > On Sep 6, 2014, at 7:59 AM, Rainer Brockerhoff wrote: > ... > ... But never do modal stuff in that block. > > Why not do modal stuff in such a block? I don't think this function > is subject to the same serializing problem I described in my previous > email. > > How is running a modal file dialog or alert from such a block > different from running it in code that just uses the main thread > (like the action method for the File > Open menu item)? That is, > unless you're advocating against all modal APIs in all circumstances, > what makes this different? I meant for the specific problem the OP posted - which, I gathered, was running an open file dialog at some point without specific action by the user _and_ while doing app startup. > -beginWithCompletionHandler: is not a drop-in replacement for > -runModal. In particular, it runs a non-modal dialog. The user can > interact with other windows, etc. That may be what you want in some > cases, but it isn't appropriate in all. Same meaning as above. I may have been mistaken in assuming that Jonathan wanted normal app startup to go ahead _while_ the open file dialog was processing. -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." http://brockerhoff.net/blog/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: setApplicationIconImage:
On 1/23/15 18:00, cocoa-dev-requ...@lists.apple.com wrote: > Date: Fri, 23 Jan 2015 09:05:54 -0800 > From: Jens Alfke > To: "Rick C." > Cc: Cocoa Cocoa-Dev > >> On Jan 23, 2015, at 1:53 AM, Rick C. wrote: >> >> Unfortunately setApplicationIconImage: works great it’s just I >> can’t find a method to put it in that will cause the change before >> the app launches. It always takes place a second after the app >> launches… > > What you're asking for is impossible, because > -setApplicationIconImage is a TEMPORARY change to the icon that only > takes effect when the method is called, and goes away when the app > quits. Read that word again: TEMPORARY. Just to complement this for the list archives, setApplicationIconImage: changes the _process_ icon in the Dock, not the _bundle_ icon in the application itself. The method should, perhaps, be called "setProcessIconImage:" :-) -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." http://brockerhoff.net/blog/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Determining preferred localizations
At 12:02 -0700 21/04/10, cocoa-dev-requ...@lists.apple.com wrote: >From: Gregory Weston >Date: Wed, 21 Apr 2010 09:59:48 -0400 >Message-ID: > >I'm trying to display a localized list of attached displays, and getting >unexpected results in Carbon and Cocoa when attempting to determine the best >localization. I did all the obvious-to-me Google searches without finding much >except a couple of other people over the years having similar issues and no >real resolution. Sample code and results follow. Hoping someone can point me >in the right direction. >... > >- (NSString*)bestLocalization:(NSArray*)inChoices >{ > NSUserDefaults* theDefaults = [NSUserDefaults standardUserDefaults]; > NSArray* theUserSettings = [theDefaults objectForKey:@"AppleLanguages"]; > NSLog(@"User Settings: %@", theUserSettings); > > NSLog(@"Choices: %@", inChoices); > > NSArray* theBestOnes = [NSBundle preferredLocalizationsFromArray:inChoices]; > NSLog(@"Chose: %@", theBestOnes); > > return [theBestOnes objectAtIndex:0]; >} I can't double-check this right now, but I solved a similar problem this way: NSArray* inChoices = [[NSBundle mainBundle] localizations]; // probably that's what you're passing in? NSArray* theBestOnes = [NSBundle preferredLocalizationsFromArray:inChoices forPreferences:[NSLocale preferredLanguages]]; HTH, -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/bb/viewtopic.php ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: cleanly support drag-to-trash for uninstall?
On 06/08/2011, at 06:48, cocoa-dev-requ...@lists.apple.com wrote: > From: Jens Alfke > Date: 6 de agosto de 2011 02:07:48 BRT > > On Aug 5, 2011, at 8:04 AM, Carl Harris wrote: > >> I have a Cocoa app that (among other things) installs an agent in launchd >> that runs in the background. The agent installation happens when the app is >> first launched after install. >> I'd like to support the drag-to-trash approach to uninstalling. Can my >> background agent listen for some notification that would allow me to detect >> that the app bundle has been dragged to the trash, so I can clean up >> properly? > > Interesting question. I’m not aware of any such notification. > > The best thing I can think of is to have your agent process periodically > check whether its file still exists, and exit if it doesn’t (or if it’s now > inside the trash). What I do in a similar situation is having the agent watch its own executable (as well as the containing app's bundle) with a kqueue (using EVFILT_VNODE and checking fro the flags NOTE_DELETE|NOTE_RENAME), and if this event occurs it unloads itself and exits. Works for me. Note that moving a running application to anywhere (not just the Trash) can lead to all sorts of path-dependent operations failing, so it's best to exit fast here. HTH, -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/blog ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Graphical Keyboard Map
On 15/08/2011, at 11:14, cocoa-dev-requ...@lists.apple.com wrote: > From: John Brownie > Date: 15 de agosto de 2011 07:19:48 BRT > > John Joyce wrote: >> Actually, I'm seeking something more concretely visual. Apple used to >> publish the keyboard maps or at least the visual representation. That is the >> only thing I am after at the moment. If I cannot get mappings for each model >> of Mac (not going too far back though) then it would not be complete. > > My app, Ukelele (referenced earlier, http://scripts.sil.org/ukelele) will > produce all you need - there's the option to specify any keyboard for which > Apple gives a KCAP resource (which is most, if not all, keyboards), so you > can get the images that way. You can either do a screen capture or print to > PDF for each one. The last time I checked, one of the physical keyboards for which no KCAP resource seems to exist is the "Latin America" one - used in most Portuguese- Spanish-speaking countries. It has 102 keys - the extra key (relative to the "generic" ANSI 101-key layout) is to the right of the left shift key. I've been trying to find a utility to build such a resource, to no avail - the format is documented but it's more work to build from scratch than I can afford at this time. At any rate, there doesn't seem to be a user-supported way of including a new KCAP into Mac OS X, and from a cursory look it seems that there's no longer a single place in the system for them - Keyboard Viewer, for one, seems to have its own copies inside the app package. I've filed rdar://9295080/ asking for a 102-key layout to be included into the system, but so far there seems to be little interest or similar requests from Latin American users. Anyway, I'll be grateful for any further information about these issues. I suppose replies to this will be off-topic for Cocoa-dev, so please email me privately. -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/blog ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: determine whether an ancillary program/task can run
On 01/09/2011, at 20:17, cocoa-dev-requ...@lists.apple.com wrote: > From: Martin Wierschin > Date: 1 de setembro de 2011 19:11:24 BRT > To: Dave DeLong > Cc: Cocoa Dev List > > Offhand does anyone know how to inspect the architecture(s) of a plain > executable file? I've been googling for a little bit and haven't hit upon > anything that works yet. Sure, that's easy to do. Define a C function like this: #include char* FindMachoHeader(char* input, cpu_type_t cpu) { struct fat_header* header = (struct fat_header*)input; if (OSSwapBigToHostInt32(header->magic)==FAT_MAGIC) { struct fat_arch* arch = (struct fat_arch*)(input+sizeof(struct fat_header)); for (NSUInteger i=0;infat_arch);i++) { if (OSSwapBigToHostInt32(arch[i].cputype)==cpu) { return input+OSSwapBigToHostInt32(arch[i].offset); } } } else if (OSSwapBigToHostInt32(((struct fat_arch*)input)->cputype)==cpu) { return input; } return NULL; } Then get the executable file with something like: NSData* executable = [NSData dataWithContentsOfMappedFile:pathToExecutableFile]; and call the function like if (FindMachoHeader([executable bytes],CPU_TYPE_X86)) { // or CPU_TYPE_POWERPC if applicable // if it returns non-null that architecture is present } (Disclaimer: partially written in Mail, proper consistency checking and so forth must be added) HTH, -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/blog ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: determine whether an ancillary program/task can run
On 02/09/2011, at 00:13, Ken Thomases wrote: > On Sep 1, 2011, at 6:42 PM, Rainer Brockerhoff wrote: > >> On 01/09/2011, at 20:17, cocoa-dev-requ...@lists.apple.com wrote: >>> From: Martin Wierschin >>> Date: 1 de setembro de 2011 19:11:24 BRT >>> To: Dave DeLong >>> Cc: Cocoa Dev List >>> >>> Offhand does anyone know how to inspect the architecture(s) of a plain >>> executable file? I've been googling for a little bit and haven't hit upon >>> anything that works yet. >> >> Sure, that's easy to do. Define a C function like this: >> >> #include >> char* FindMachoHeader(char* input, cpu_type_t cpu) { >> ... > You might be interested in the functions listed in the arch(3) man page. > http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/arch.3.html Right, the arch(3) function would do for the OP. For my special case, I didn't use them when I wrote that function because I wanted to do further processing on the executable, not just check if the architecture was there. -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/blog ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: UTI in Lion
On 22/09/2011, at 21:01, cocoa-dev-requ...@lists.apple.com wrote: > From: Charles Srstka > Date: 22 de setembro de 2011 19:19:04 BRT > To: "Gerriet M. Denkmann" > Cc: cocoa-dev@lists.apple.com > > A while ago someone posted on this list that they needed to list all files > that were applications, including old Classic apps. To do that the old way, > you’d have to check for .app, bundles with the package bit set and ‘APPL’ in > the PkgInfo file, and the “APPL”, “APPC”, “APPD”, “APPE”, “cdev”, “dfil”, and > probably some other type codes I’m forgetting. With UTIs, you just check for > com.apple.application and be done with it. Good point, Charles. On the other hand, I was in this exact situation some years ago - not only having to list all apps, but also having to distinguish which were Classic and which were not (and exclude command-line apps) - and it turned out the UTI algorithm wasn't sufficient for that, so I had to my own. In defense of UTIs, they were new at the time and the algorithm didn't cover all those possibilities and now in Lion, with Classic deprecated for so long, it probably no longer covers them all either. PowerPC-only apps may be dropped out in 10.8, who knows. "Check for com.apple.application and be done with it" is very convenient, and OK as long as we remember it's not magic, and that the results with change with different releases. -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/blog ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Finder Integration
On 30/09/2011, at 09:43, cocoa-dev-requ...@lists.apple.com wrote: > From: Matt Gough > Date: 30 de setembro de 2011 05:21:06 BRT > > Firstly there is no official way to do this, all the solutions you see in the > wild are hacks of one sort or another. > > Having said that, I had to implement what you are asking for (overlays on > icons) and did it via SIMBL. Unfortunately I can't share code or say too much > about what what is needed, but it would certainly help if you understood > method swizzling and found a way to dump all the Obj_c classes that the > Finder uses internally. > > On 29 Sep 2011, at 20:39, Damon Allison wrote: >> I am researching options for integrating with Finder. In particular, I would >> like my application to provide file and directory icon overlays similar to >> how Dropbox.app overlays green and blue images on top of file and folder >> images. I've never used Dropbox, but - on the offhand chance that you want overlays only on certain icons, not generic ones - you can add overlays by adding a 'badg' resource to the file's resource fork (or to the hidden .icon\r file inside the folder). Check out: http://developer.apple.com/legacy/mac/library/documentation/Carbon/Conceptual/Icon_Service_nd_Utilities/IconServUtili.pdf and http://www.cocoabuilder.com/archive/cocoa/95797-finder-icon-badging.html HTH, -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/blog ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Why Don't Cocoa's (Un)Archiving Methods return Errors?
On 29/07/2011, at 20:47, cocoa-dev-requ...@lists.apple.com wrote: > From: Jens Alfke > Date: 29 de julho de 2011 17:15:19 BRT > > On Jul 29, 2011, at 11:12 AM, Jerry Krinock wrote: > >> When invoking -archivedDataWithRootObject: on, say, dictionary, finding an >> un-encodeable object buried somewhere in the dictionary would seem to be >> quite common. > > This is a case of passing invalid data, so throwing an exception is > appropriate. It’s implicit that when you archive an object graph, all the > objects in it must be archivable. > ... > Not to start another flamewar, but this is a great example of why Exceptions > Are Good, since you don’t have to rip apart your API and add lots of extra > parameters just to add error handling. Looking back at code I wrote years ago, I see that I usually did things like @try { someObject = [NSKeyedUnarchiver unarchiveObjectWithData:someData]; } @catch (id exception) { someObject = nil; // or some other reasonable default state // mark someData as being corrupted to avoid its reuse } and this works well in my (admittedly not overly thorough) testing. I do the same when reading in nib files, image resources, etc.. However, I've also seen cautions that after throwing _any_ exception whatsoever we should terminate the application as soon as possible. Granted that NSKeyedUnarchiver might have left some memory leaks or partially uninitialized objects somewhere, but unarchiving an invalid object should happen rarely if at all... and ordinarily my own code should never get pointers to such objects, anyway. While personally I never had any problems with that try/catch block, I'd be interested in other opinions and experiences. -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/blog ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Get size of folder
At 21:54 -0700 18/08/09, cocoa-dev-requ...@lists.apple.com wrote: >From: PCWiz >Date: Tue, 18 Aug 2009 21:17:30 -0700 >Message-ID: <9c08262c-4924-4840-8ca3-f4548db20...@gmail.com> > >I need a good method to find the size of a file or folder exactly as displayed >in Finder. I've tried every method I could find on the internet, from using >the du shell utility with NSTask to using the Carbon file manager. I need >something that will work under heavy load (processing hundreds or thousands of >files). The methods I've tried, some of them work but fail under load. Others >just don't return a accurate file size, or they work for some files/folders >and mess up on others. What's the easiest way to go about doing this? Somewhat belatedly, you may want to try out the FolderSweep code at: http://www.brockerhoff.net/src/index.html or at: http://mattgemmell.com/2008/04/10/foldersweep-source-code You can directly get the data and resource fork sizes for every scanned file. -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/bb/viewtopic.php ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Determine encoding of file
At 16:06 -0700 30/07/10, cocoa-dev-requ...@lists.apple.com wrote: >From: Dave DeLong >Date: Fri, 30 Jul 2010 16:09:22 -0600 >Message-ID: >... >Given a file, how can I determine the NSStringEncoding of the file, without >reading the entire file into memory? (If the file isn't a text file, then >defaulting to NSUTF8StringEncoding is just fine, since my code will only work >properly if I'm working with text files anyway) Beyond what others have already answered, one example heuristic can be found in this sample code: http://brockerhoff.net/src/FolderSweep.zip check the last method in AppController.m. HTH, -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Blog: http://brockerhoff.net/blog ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Code sign verification in Leopard
At 08:35 -0700 17/08/10, cocoa-dev-requ...@lists.apple.com wrote: >From: Arun >Date: Tue, 17 Aug 2010 21:01:06 +0530 >Message-ID: >Content-Type: text/plain > >I am using Mac OS X 10.5.8 and xcode v3.1. >I have created a Self Code signing identity using Keychain Access >application. The name of the Code signing identity is "arun". > >Using this identity i have signed a binary using the below command. > >codesign -s arun -r="designated => anchor trusted" -f arun The proper list for this is probably apple-c...@lists.apple.com... Anyway, here's the way I do it with my self-signed cert: codesign -s myidentity -i "my.qualified.bundle.id" -fv mybundlepath >To verify the code sign i am using the following command which throws the >error as highlighted below. > >codesign -v -R="anchor trusted" arun >arun: does not satisfy its designated Requirement >*test-requirement: failed to satisfy code requirement(s)* To verify, run: codesign -dvv -r- mybundlepath which should print Authority="myidentity" and a few lines later root = H"lotsofhexcharacters" note that anyone can change and re-sign your bundle with the same identity name, but the "lotsofhexcharacters" are unique to your own self-signed certificate. Also, running codesign -vv mybundlepath should print "valid on disk" if the bundle is intact, "code or signature modified" otherwise. HTH, -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Blog: http://brockerhoff.net/blog ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Adding subviews to collapsed splitview
At 11:54 -0700 01/10/10, cocoa-dev-requ...@lists.apple.com wrote: >From: Gideon King >Date: Sat, 2 Oct 2010 04:51:10 +1000 >Message-ID: <3dda7a4e-c5d4-45d9-bf47-0a585ce4d...@novamind.com> > >Hi, I have a splitview (actually an RBSplitView), split into left and right, >that I add another RBSplitView to at runtime in the right subview, and that >split view that is added has a text view and an outline view as its subviews. >All this works fine when the pane where I put the splitview that contains the >outline view and text view is not collapsed. I can resize it, collapse and >expand it etc, and it all looks good. >... >Can anyone enlighten me as to how to add subviews to a collapsed panel in such >a way that it will resize properly when expanded? Howdy Gideon, I'm the author of RBSplitView. Is there any special reason for you to add the subview at runtime? And are you actually adding the inner RBSplitView directly as a subview to the outer one (which is recommended), or inserting it into an empty RBSplitSubview? You could try calling -adjustSubviews on the inner RBSplitView after adding it, which should force it to recalculate its own subviews. HTH, -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Blog: http://brockerhoff.net/blog ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to create secondary Thread that listens to event taps?
At 12:01 -0700 17/10/10, cocoa-dev-requ...@lists.apple.com wrote: >From: eveningnick eveningnick >Date: Sun, 17 Oct 2010 20:25:02 +0300 >Message-ID: > >So, i decided to do the following - i will execute the "long action" >in a main thread, and create an "Esc-listening thread" that will >install a system-wide keyboard EventTap (which watches ESC presses, >and if it gets any, it rises the cancellation flag - this flag is >periodically checked in the main thread's "long alhorithm"). > >The thing i can't understand - is how to make that secondary thread to >have a run loop, and how to make it not to finish as soon as i have >created it - but to watch its own run loop for "event taps"'s events. You create the secondary thread, install the event tap in it as usual - that is, create a run loop source for the tap and add the source to the current run loop returned by CFRunLoopGetCurrent() - and then, erhm, run the run loop in a loop :-) Something like (warning: typed in Eudora): while (someCondition) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; SInt32 result = CFRunLoopRunInMode(kCFRunLoopDefaultMode,0.5,YES); [pool drain]; if (result==kCFRunLoopRunStopped)) { return; } } should work. HTH, -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Blog: http://brockerhoff.net/blog ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to create secondary Thread that listens to event taps?
At 21:11 +0300 19/10/10, eveningnick eveningnick wrote: > > You create the secondary thread, install the event tap in it as usual - > > that is, create a run loop source for the tap and add the source to the > > current run loop returned by CFRunLoopGetCurrent() - and then, erhm, run > > the run loop in a loop :-) >> >> Something like (warning: typed in Eudora): >>while (someCondition) { >>NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; >>SInt32 result = >> CFRunLoopRunInMode(kCFRunLoopDefaultMode,0.5,YES); >>[pool drain]; >>if (result==kCFRunLoopRunStopped)) { >>return; >>} >>} > > should work. > >Why did you give 0.5 as the second param of CFRunLoopRunInMode? Is it >the optimal value? That means the while(condition) loop cycles every 0.5 seconds, even if nothing happens in the runloop. A too-low value will make your thread activate too often (making it use more CPU when idle) and a too-high value will make it too slow to react to "condition" being set to NO. I usually set something between 0.5 and 1; it's optimal in the sense "works-for-me" ;-) -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Blog: http://brockerhoff.net/blog ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to create secondary Thread that listens to event taps?
At 22:44 -0700 19/10/10, Chris Hanson wrote: >On Oct 19, 2010, at 12:41 PM, Rainer Brockerhoff wrote: > >> A too-low value will make your thread activate too often (making it use more >> CPU when idle) and a too-high value will make it too slow to react to >> "condition" being set to NO. I usually set something between 0.5 and 1; it's >> optimal in the sense "works-for-me" ;-) > >Rather than do that, create another, custom CFRunLoopSource that can be used >to wake up the run loop (via CFRunLoopSourceSignal) when the condition changes. > >Then instead of just > > condition = NO; > >use > > condition = NO; > CFRunLoopSourceSignal(mySource); > >to wake the run loop immediately. That'll let you set a nice high timeout >rather than something low like 0.5 or 1, and prevent you from wasting CPU. Good point Chris. When I first used that code, I had a more complex condition to poll (not just a single BOOL). For the simplified case, the custom source is most efficient. -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Blog: http://brockerhoff.net/blog ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSSavePanel runModal isn't working in sandbox?
On Jun 6, 2012, at 13:08 , cocoa-dev-requ...@lists.apple.com wrote: > Date: Wed, 06 Jun 2012 14:50:17 +1000 > From: Graham Cox > To: Samuel Williams > Message-ID: > > Are you aware that this class is riddled with severe bugs under the current > sandbox implementation? > > The dev forums will reveal more details. > > Also, NSSavePanel doesn't inherit from NSPanel under sandboxing, so if you > are expecting to use inherited methods, they don't work. > ... > On 06/06/2012, at 1:41 PM, Samuel Williams wrote: >> >> I'm having trouble with NSSavePanel runModal in a sandbox: >> >> NSSavePanel * savePanel = [NSSavePanel savePanel]; >> savePanel.title = @"Document Migration"; >> savePanel.directoryURL = url; >> savePanel.nameFieldStringValue = [url lastPathComponent]; >> savePanel.allowedFileTypes = [NSArray arrayWithObject:typeName]; >> savePanel.message = @"Your document needs to be upgraded."; >> >> [savePanel setCanSelectHiddenExtension:YES]; >> [savePanel setExtensionHidden:YES]; >> >> NSInteger result = [savePanel runModal]; I've had no problems at all with NSSavePanel under the sandbox (the inherited methods limitation that Graham mentioned excepted). My usage looks almost exactly like the code above except that I call -beginSheetModalForWindow:completionHandler: instead of -runModal. BUT. You need the com.apple.security.files.user-selected.read-write entitlement set to YES. HTH, -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/blog ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Defining subclasses at run time
On Jun 11, 2012, at 13:20 , cocoa-dev-requ...@lists.apple.com wrote: > Date: Mon, 11 Jun 2012 12:35:13 +0300 > From: Oleg Krupnov > Message-ID: > > > I'm solving the following problem. I have a huge array of items of the > same class MyItem. All items need to share a certain global "context" > variable. Normally, I would wrap access to this variable in a > class-level (+) method of MyItem, like +[MyItem getContext]. > > Now the problem is that I need multiple arrays of MyItems have > different contexts. The solution could be to add the context pointer > as an ivar to each MyItem instance, but I would not like to waste > memory on that (the arrays are huge). You could subclass NSArray (tricky because it's a class cluster), adding the context variable as an ivar to that; or make your own class containing that context and the actual array, and implementing all the proper methods. However, what I used in a similar situation is objc_getAssociatedObject() and objc_setAssociatedObject() in objc/runtime.h. Look them up. HTH, -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/blog ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSSplitView question - how to implement my own "adjustViews" style method
On Jul 3, 2012, at 01:46 , cocoa-dev-requ...@lists.apple.com wrote: > Date: Tue, 03 Jul 2012 10:14:21 +1000 > From: Graham Cox > Message-ID: > > On 03/07/2012, at 12:21 AM, Motti Shneor wrote: > >> I really need an advice here. > > This will sound flippant but it's not meant to be: implement your own split > view. RBSplitView will do exactly what you want. However, unfortunately it's stuck in the times when IB was a separate app with plugins. If you can manage to set up your views in code (at least the split view and its subviews, then pull in the rest), it still seems to work well. If you want to roll your own, my advice would be to at least glance at the RBSplitView code (and docs) beforehand. Looking back, the crucial decision seems to have been to implement RBSplitSubviews to handle most of the work. Good luck, ;-) -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/blog ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSSplitView question - how to implement my own "adjustViews" style method
On Jul 3, 2012, at 11:03 , Andy Lee wrote: > I haven't used RBSplitView, but it sounds like it might be handy to have a > method for replacing an already-set-up NSSplitView with an RBSplitView. Maybe > it could be a category method on NSSplitView, something like this: > ... > This way you can still use IB to lay out the subviews of the split view, > using a regular NSSplitView. In awakeFromNib, you can swap out the split view > by calling this method. Now that's an interesting idea, thanks Andy! I'll look into it soon, I hope. Handiest way might be to implement something like +[RBSplitView transmogrify:(NSSplitView*)someSplitView]. All the cool extra RBSplitSubview properties would, of course, have to set manually... hm. -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/blog ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSSplitView question - how to implement my own "adjustViews" style method
On Jul 3, 2012, at 12:11 , Andy Lee wrote: > On Jul 3, 2012, at 10:31 AM, Rainer Brockerhoff wrote: >> Now that's an interesting idea, thanks Andy! I'll look into it soon, I hope. > > P.P.S. I'm not sure how to deal with autolayout constraints that might get > broken. Does replaceSubview:with: transfer constraints that were on the old > view to the new view? (It would have to do some behind-the-scenes trickery, > since NSLayoutConstraint is immutable.) Well, RBSplitView was written way before autolayout and ARC, so I'm sure supporting either or both will need a complete rewrite... -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/blog ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSSplitView question - how to implement my own "adjustViews" style method
On Jul 19, 2012, at 11:06 , cocoa-dev-requ...@lists.apple.com wrote: > Date: Thu, 19 Jul 2012 11:42:07 +0300 > From: Motti Shneor > Message-ID: > > Thanks for the note. Indeed, RBSplitView is a complete, functional and > feature-loaded class, but it is also lagging behind current Cocoa > developments, and does not integrate well XCode 4.x and with SDK 10.7 or and > SDK 10.8. Testing with it I saw problems in: > 1. Look and feel (not coherent with recent standard NSSplitView variants). > 2. Integration with dev. environment (Apple broke the plugin architecture of > Interface-Builder in XCode 4). Everything must be done programmatically. > 3. Does not mix well with auto-layout views. We don't yet use auto-layout (or > we wouldn't have so much trouble with the split-view - it does very well with > auto-layout policies.) Thanks. I was waiting for a solution to #2 (but it seems none will be forthcoming) and #3 caught me by surprise - I'd hoped autolayout would help me in making a lighter-weight solution for Xcode4 and/or 10.7. So far that doesn't seem workable either. Can you elaborate on #1, by private email? Offhand I don't see any look&feel differences. Thanks, -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/blog ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Repositioning another app's windows?
On Aug 1, 2012, at 11:38 , cocoa-dev-requ...@lists.apple.com wrote: > Date: Wed, 01 Aug 2012 01:07:15 -0500 > From: Charles Srstka > Message-ID: > > On Jul 31, 2012, at 11:18 PM, Jerry Krinock wrote: > >> Neither way is 100% reliable. Accessibility probably requires that "Enable >> Access for assistive devices" be on in System Preferences. I don't see why >> we have that stupid checkbox. At least, in 10.8 it's on by default in a new >> account. > > My guess is that Apple probably considered it a security flaw to have > applications able to control applications' GUI elements by default. Using the checkbox gives blanket permission for all processes, which is rather extreme. A workaround for the "Enable Access" checkbox is to call AXMakeProcessTrusted() on your binary, which sets the setgid bit and uses a special "accessibility" group - needing a complex dance nowadays to ask for the admin password. (And, of course, making the app uneligible for the Mac App Store.) A similar reasoning applies to using event taps. I have an open enhancement request (rdar:///9507141) to use entitlements for this, proposing, for instance: > - com.apple.security.events.keyboard - allows the process to install keyboard > event taps > - com.apple.security.events.mouse - allows the process to install mouse event > taps > - com.apple.security.events.other - allows the process to install > other/special taps > - com.apple.security.accessibility - allows the process to use accessibility > even if turned off in System Preferences. > - This also opens up the possibility of the system alerting the user the > first time an application with these capabilities is run, or even downloaded. Feel free to dupe or expand on this. -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/blog ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to make Obj-C collection subscripting work on iOS 5?
On Aug 20, 2012, at 19:41 , cocoa-dev-requ...@lists.apple.com wrote: > Date: Mon, 20 Aug 2012 15:16:43 -0700 > From: Greg Parker > Message-ID: <4cc28fb2-6935-4829-8606-0db9cf6ac...@apple.com> > > On Aug 20, 2012, at 2:02 PM, Jens Alfke wrote: >> On Aug 20, 2012, at 12:52 PM, I wrote: >>> My first thought was to declare some categories on NSArray and NSDictionary >>> to define those methods, but that's likely to cause issues when iOS 6 comes >>> out and already includes those methods — I'll get compile errors (which I >>> can work around with #ifdefs) but also a warning at launch time because the >>> methods are declared in two places. > > IIRC there are some subscript-able classes that libarclite does not upgrade > (NSOrderedSet, maybe?) so you still need to test thoroughly on older > deployment targets. I can confirm NSOrdered[Mutable]Set isn't covered by libarclite. Here's what I'm using for that (easily extended to other classes: @interface NSOrderedSet() - (id)objectAtIndexedSubscript:(NSUInteger)idx; @end @interface NSMutableOrderedSet() - (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx; @end static void PatchClass(Class class ,SEL newsel, SEL oldsel) { id instance = [[class alloc] init]; class = [instance class]; [instance release]; if (![class instancesRespondToSelector:newsel]) { if ([class instancesRespondToSelector:oldsel]) { Method method = RBXCALL(class_getInstanceMethod)(class, oldsel); if (method) { IMP imp = RBXCALL(method_getImplementation)(method); if (imp) { const char* enc = RBXCALL(method_getTypeEncoding)(method); if (enc) { RBXCALL(class_addMethod)(class, newsel, imp, enc); } } } } } } static void SetObjectSwapped(id myself, SEL _cmd, id obj,NSInteger idx) { [myself replaceObjectAtIndex:idx withObject:obj]; } static void PatchClassSwap(Class class, SEL newsel) { id instance = [[class alloc] init]; class = [instance class]; [instance release]; if (![class instancesRespondToSelector:newsel]) { if ([class instancesRespondToSelector:@selector(replaceObjectAtIndex:withObject:)]) { RBXCALL(class_addMethod)(class, newsel, (IMP)SetObjectSwapped, "v@:@q"); } } } ...and early in the app's startup I call: PatchClass([NSOrderedSet class], @selector(objectAtIndexedSubscript:), @selector(objectAtIndex:)); PatchClass([NSMutableOrderedSet class], @selector(objectAtIndexedSubscript:), @selector(objectAtIndex:)); PatchClassSwap([NSMutableOrderedSet class], @selector(setObject:atIndexedSubscript:)); This runs fine on both 10.7 and 10.8, so it should also work on iOS5 and iOS6. HTH, -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/blog ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to make Obj-C collection subscripting work on iOS 5?
On Aug 20, 2012, at 20:41 , Rainer Brockerhoff wrote: > I can confirm NSOrdered[Mutable]Set isn't covered by libarclite. Here's what > I'm using for that (easily extended to other classes: Oops. Forgot to take out my RBXCALL() macros (which just add a trivial test), so below's the corrected version: @interface NSOrderedSet() - (id)objectAtIndexedSubscript:(NSUInteger)idx; @end @interface NSMutableOrderedSet() - (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx; @end static void PatchClass(Class class ,SEL newsel, SEL oldsel) { id instance = [[class alloc] init]; class = [instance class]; [instance release]; if (![class instancesRespondToSelector:newsel]) { if ([class instancesRespondToSelector:oldsel]) { Method method = class_getInstanceMethod(class, oldsel); if (method) { IMP imp = method_getImplementation(method); if (imp) { const char* enc = method_getTypeEncoding(method); if (enc) { class_addMethod(class, newsel, imp, enc); } } } } } } static void SetObjectSwapped(id myself, SEL _cmd, id obj,NSInteger idx) { [myself replaceObjectAtIndex:idx withObject:obj]; } static void PatchClassSwap(Class class, SEL newsel) { id instance = [[class alloc] init]; class = [instance class]; [instance release]; if (![class instancesRespondToSelector:newsel]) { if ([class instancesRespondToSelector:@selector(replaceObjectAtIndex:withObject:)]) { class_addMethod(class, newsel, (IMP)SetObjectSwapped, "v@:@q"); } } } ...and early in the app's startup I call: PatchClass([NSOrderedSet class], @selector(objectAtIndexedSubscript:), @selector(objectAtIndex:)); PatchClass([NSMutableOrderedSet class], @selector(objectAtIndexedSubscript:), @selector(objectAtIndex:)); PatchClassSwap([NSMutableOrderedSet class], @selector(setObject:atIndexedSubscript:)); This runs fine on both 10.7 and 10.8, so it should also work on iOS5 and iOS6. Sorry about that. -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/blog ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Dismissing Open dlog before doc actually opens
On 14/08/13 16:00 , cocoa-dev-requ...@lists.apple.com wrote: Date: Wed, 14 Aug 2013 14:58:42 -0400 Message-ID: <20130814185842.823741...@mail.rogue-research.com> On Wed, 14 Aug 2013 09:03:59 -0500, Steve Mills said: There most certainly is not a deeper issue with my code. Run this and you'll see for yourself: -(IBAction) openDocument:(id)sender { NSOpenPanel*p = [NSOpenPanel openPanel]; if([p runModal] == NSFileHandlingPanelOKButton) { [p orderOut:self]; // Simulate code that takes 5 seconds to open a document: sleep(5); } } Apologies for being late to the thread. I have a similar situation: the NSOpenPanel references a potentially large document which may take nearly a minute to fully open. (I don't use NSDocument, however.) My solution was to pre-create an empty document window and attach the NSOpenPanel to it as a modal sheet with a completion handler like this: NSOpenPanel* panel = [NSOpenPanel openPanel]; [panel beginSheetModalForWindow:theWindow completionHandler:^(NSInteger result) { if (result==NSFileHandlingPanelOKButton) { [self performSelectorOnMainThread:@selector(openTheseURLS:) withObject:[panel URLs] waitUntilDone:NO]; } } I don't need to call orderOut: at all. The main runloop will close the sheet and then process the selected URLs, updating the window as it does so. Not sure how this would play out with NSDocument though... :-/ HTH, -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." http://brockerhoff.net/blog/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Problem with NSImage and .PNG file
At 03:26 -0700 16/08/08, [EMAIL PROTECTED] wrote: >From: Matt <[EMAIL PROTECTED]> >Date: Fri, 15 Aug 2008 13:54:32 -0700 >Message-ID: <[EMAIL PROTECTED]> >Subject: Problem with NSImage and .PNG file >Message: 4 > >I have an image that is 7200x32 pixels, which is used to store a series of >32x32 tiles. When drawing from this NSImage, the further towards the end of >the image (right edge) the subrect goes, the blurrier it gets drawn. >... >I found that the .PNG NSImage was returning a width of 7199.099 pixels, >instead of 7200. Manually setting the NSImage's width to 7200 before drawing >fixed this issue and resulted in the correct, non-blurry subrectangles being >drawn. > >Has anyone encountered this issue before? Is this a bug within NSImage's >handling of PNG's or could this be a problem with my image file itself, a >DPI issue perhaps? It's a bug in the image itself, or rather, in the generating software. I have a bug filed (still open, rdar://5532687) which says, in part: >When saving .png files, Preview 4.0(467) generates incorrect values for the >file's DPI. >... >See http://www.libpng.org/pub/png/spec/1.1/PNG-Chunks.html#C.pHYs >The 'pHYs' chunk can specify either "unknown unit" (which makes the file >default to 72 dpi when opened) or "meter". Preview now seems to generate the >latter specification. As 72 dpi don't fit exactly into metric units, the >measurement is rounded up, producing the 72.009 value. >Solution: >When saving 72 dpi pictures, specify "unknown unit" in the 'pHYs' chunk. I haven't checked if that has been fixed in Leopard Preview, though; I suppose not, as the bug's still open. -- Rainer Brockerhoff <[EMAIL PROTECTED]> Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/bb/viewtopic.php ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: App name from Bundle Identifier?
At 17:06 -0700 12/09/08, [EMAIL PROTECTED] wrote: >From: Jonathan Hess <[EMAIL PROTECTED]> >References: <[EMAIL PROTECTED]> >In-Reply-To: <[EMAIL PROTECTED]> >Date: Fri, 12 Sep 2008 14:34:59 -0700 >Message-ID: <[EMAIL PROTECTED]> >... >Before displaying a localized name for your bundle, the Finder compares the >value of this key against the actual name of your bundle in the file system. >If the two names match, the Finder proceeds to display the localized name from >the appropriate InfoPlist.strings file of your bundle. If the names do not >match, the Finder displays the file-system name. Just as a heads-up/quibble, localized bundle names work only for .apps, not for .bundles (or any other common bundle extension that I tested against). I filed rdar://6209849 ... -- Rainer Brockerhoff <[EMAIL PROTECTED]> Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/bb/viewtopic.php ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Creating alias programatically
At 15:12 -0700 23/09/08, [EMAIL PROTECTED] wrote: >From: Ken Thomases <[EMAIL PROTECTED]> >References: <[EMAIL PROTECTED]> >In-Reply-To: <[EMAIL PROTECTED]> >Date: Tue, 23 Sep 2008 15:40:47 -0500 >Message-ID: <[EMAIL PROTECTED]> > >Apple has never officially supported applications creating alias files. In >fact, the documentation often refers to them as "Finder alias files" because, >as far as Apple is concerned, only the Finder should ever be creating them. >See the section "Working With Finder Alias Files" in the Alias Manager >Reference, and notice that there are only functions for examining and reading >alias files, not creating them. For that reason, the supported way to create >an alias file is to use Apple Events to ask the Finder to create it for you. That's news to me... I really can't recall right now where the alias file format was officially documented, but in the Classic days it was quite acceptable to create them yourself. (They were invented before Apple Events, after all ;-) ) >From: chaitanya pandit <[EMAIL PROTECTED]> >References: <[EMAIL PROTECTED]> > <[EMAIL PROTECTED]> > <[EMAIL PROTECTED]> > <[EMAIL PROTECTED]> > <[EMAIL PROTECTED]> > <[EMAIL PROTECTED]> >In-Reply-To: <[EMAIL PROTECTED]> >Date: Wed, 24 Sep 2008 03:27:59 +0530 >Message-ID: <[EMAIL PROTECTED]> > >Here is what i did: >... > long handleSize = GetHandleSize((Handle)aliasHandle); > int wrote = write(fd, &handleSize, sizeof(long)); > wrote = write(fd, *aliasHandle, handleSize); > close(fd); That's the error. An alias file isn't just an alias handle written out into the data fork. You have to create a resource file (with a resource fork), the file's Finder flags should have the kIsAlias bit turned on, and then you save the alias Handle as resource ID#0 with type 'alis'. Details in , if I recall correctly. -- Rainer Brockerhoff <[EMAIL PROTECTED]> Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/bb/viewtopic.php ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Creating alias programatically
At 18:15 -0500 23/09/08, Ken Thomases wrote: >On Sep 23, 2008, at 5:54 PM, Rainer Brockerhoff wrote: >>That's news to me... I really can't recall right now where the alias file >>format was officially documented, but in the Classic days it was quite >>acceptable to create them yourself... > >From the legacy Inside Macintosh ><http://developer.apple.com/documentation/mac/Toolbox/Toolbox-459.html>: >... >From legacy Technical Note TB535: Finder Q&Aa ><http://developer.apple.com/technotes/tb/tb_535.html>: >... >>Once again, DTS urges that you not create alias files from within an >>application. > >Just because the format was documented doesn't mean that Apple supported the >creation of alias files by third-party applications. Thanks for setting me straight on that (also to Charles Srstka). I dug out my paper copy of Inside Mac VI from last millenium's stratum in my office, and indeed it confirms what you say. However, it also says storing alias records in files for private use was already generally allowed. Since the format of the alias record itself isn't documented, even today, this indicates that Apple still can introduce new formats (as they have done since then), but on the other hand, for all practical purposes, stored records should work until alias records become completely unsupported. In other words, the Finder may even change its current implementation of alias files, but the old format should still work. In Mac OS X 10.1.x days and up to now, my XRay utility had commands to create alias files in various formats; no problems ever were reported. In the present situation, where the legacy resource file format, etc. is for all intents set in stone, but many things still depend on it (custom icons, icon badges, alias files, and so forth), I would say that, for most purposes, _today_ it's safe to create an alias file on HFS volumes, despite those old warnings. I hasten to add this is my personal, perhaps cynically pragmatic, view. ;-) -- Rainer Brockerhoff <[EMAIL PROTECTED]> Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/bb/viewtopic.php ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Need for a creator code?
At 15:21 -0700 01/04/08, [EMAIL PROTECTED] wrote: >From: Andrew Farmer <[EMAIL PROTECTED]> >References: <[EMAIL PROTECTED]> >In-Reply-To: <[EMAIL PROTECTED]> >Date: Tue, 1 Apr 2008 13:26:58 -0700 >Message-ID: <[EMAIL PROTECTED]> > >On 01 Apr 08, at 12:59, Marc Respass wrote: >>I haven't registered for a creator code since System 7.5. Apple has >>information and registration page >>(http://developer.apple.com/datatype/index.html) about it but no indication >>if it's actually still required. Can anyone tell me if it is still required >>or maybe point me at the right information? > >Type and creator codes have been deprecated since Tiger, which introduced >UTIs. (Maybe even longer; I'm not sure.) Either way, you can safely forget >they ever existed. Type and Creator codes are alive and well in 10.5.x, and I haven't seen any mention that they're deprecated. They're still used by LaunchServices to bind documents to applications. UTIs haven't substituted them, mostly because there's no field in HFS+ that directly defines a UTI for a specific file; instead the UTI is deduced from type, creator and extension (perhaps also from file contents in some cases). What actually happens is that file type is checked first, then file extension, then file creator. LaunchServices matches them, in that order, to registered applications. The same metadata are also used to produce UTIs for that file, which are also used for matching. It's still useful to register a creator code for your application if you have documents/files that have no extensions (in that case, also use a type), or that have some otherwise common extension, but still need to show your app's document icon. All-lowercase code are reserved. There used to be some problems with using codes that contained MacRoman characters with the high bit set - the codes use MacRoman but the PkgInfo files (which are mostly obsolete these days) used UTF8. I suppose that should work now, although I haven't checked. Registering a code is much faster now - you get a response within minutes, instead of the week it used to take in the System 7 days. -- Rainer Brockerhoff <[EMAIL PROTECTED]> Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/bb/viewtopic.php ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Open-source NSToolbar?
At 09:26 -0700 08/04/08, [EMAIL PROTECTED] wrote: >From: John Stiles <[EMAIL PROTECTED]> >References: <[EMAIL PROTECTED]> >In-Reply-To: <[EMAIL PROTECTED]> >Date: Tue, 08 Apr 2008 09:25:57 -0700 >Message-ID: <[EMAIL PROTECTED]> > >Well, I was thinking more along the lines of an RBSplitView, somethingyou can >just drop into your nib/code and suddenly your toolbars arebetter :) Is this fame, or what? :-P OK, I've noted that there might be demand for a RBToolBar... Although I've so far avoided having to use NSToolBar, and disliked it when I tried to some years ago, I hear it's gotten much better in Leopard? I'm more inclined to publish a RBFileObject at this time, however, since I've got most parts of that already done... -- Rainer Brockerhoff <[EMAIL PROTECTED]> Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/bb/viewtopic.php ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: recursive dir searching
At 11:09 -0700 10/04/08, [EMAIL PROTECTED] wrote: >From: "Wesley Smith" <[EMAIL PROTECTED]> >Date: Tue, 8 Apr 2008 17:20:25 -0600 >Message-ID: <[EMAIL PROTECTED]> > >I've been trying to use >NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] >enumeratorAtPath:dir]; > >to recursively search for a file in a given directory but am coming >across some minor details that I'm not sure what the best way to deal >with is. I just posted some code (with sample app) which you might find useful for recursive directory searching: http://www.brockerhoff.net/src/ (scroll down to "FolderSweep"). MIT license (with attribution), so feel free to use it. HTH, -- Rainer Brockerhoff <[EMAIL PROTECTED]> Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/bb/viewtopic.php ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Calculating file size
At 02:49 -0700 27/04/08, [EMAIL PROTECTED] wrote: >From: Jens Alfke <[EMAIL PROTECTED]> >References: <[EMAIL PROTECTED]> >In-Reply-To: <[EMAIL PROTECTED]> >Date: Sat, 26 Apr 2008 21:33:26 -0700 >Message-ID: <[EMAIL PROTECTED]> > >On 26 Apr '08, at 6:50 PM, Cocoa Dev wrote: > >>I was wondering what was the best way to calucate folder size with cocoa? I >>was able to do this but it does not include resource forks: > >I think you'll need to drop down to a lower-level API to get the resource fork >size; probably one of the "*CatInfo*" calls in . I can't really give >specific advice because I haven't used those much since OS 9, and they've >changed a lot since. Check out the FolderSweep code at: http://www.brockerhoff.net/src/ (at the end of the page). You would pass in the bit masks asking for both logical fork sizes, and sum them for every file (they're 64bit unsigned integers). -- Rainer Brockerhoff <[EMAIL PROTECTED]> Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/bb/viewtopic.php ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSSplitView
At 14:51 -0800 31/12/08, cocoa-dev-requ...@lists.apple.com wrote: >From: David Blanton >Date: Wed, 31 Dec 2008 15:22:49 -0700 >Message-ID: > >How does one make a connected horiz-vert split view like in Xcode, you know, >one control point to size in both directions? RBSplitView does that automagically if you nest two of them: http://www.brockerhoff.net/src/rbs.html I really must find time to update it, but people tell me it still works well. HTH, -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/bb/viewtopic.php ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: App Listener?
At 05:55 -0800 08/01/09, cocoa-dev-requ...@lists.apple.com wrote: >From: Jerry Krinock >References: <63539670901072146w570a8dc1wc13c58b8ecb43...@mail.gmail.com> > > <63539670901072246j1f659c63q33a73b501233f...@mail.gmail.com> > <63539670901072246u6b783883n69fdf7a44fb0a...@mail.gmail.com> >In-Reply-To: <63539670901072246u6b783883n69fdf7a44fb0a...@mail.gmail.com> >Date: Thu, 8 Jan 2009 05:39:57 -0800 >Message-ID: <406b8377-613f-49d2-a3de-2ba381346...@ieee.org> > >On 2009 Jan, 07, at 22:46, Chunk 1978 wrote: > >>does this work with Dashboard? it seems that dashboard is a >>background application that's always open... > >Well, obviously it does not. > >You'd need a NSWorkspaceDidActivateApplicationNotification, but it looks like >there is no such thing. You could periodically poll -[NSWorkspace >activeApplication], but I hope someone has a better idea, because if you do I >would not want your process running on my Mac. Today, the only solution seems to be to install a Carbon Event handler for the {kEventClassApplication, kEventAppFrontSwitched} event. Even if such a NSWorkspace notification were to appear in a future version of Mac OS X, I'd be interested in a lower-level solution. I have a background process that can't link to AppKit due to security restrictions, and Carbon Events have gone away for 64-bit processes. I did look at how HIToolbox does its magic, but it appears to be listening to a private notification from the Process Manager. And BSD, of course, has no concept of "front process". If nobody knows another public API for an app activation notification, I'll file an enhancement request. -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/bb/viewtopic.php ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: App Listener?
At 15:09 + 08/01/09, James Montgomerie wrote: >On 8 Jan 2009, at 14:14, Rainer Brockerhoff wrote: >>Today, the only solution seems to be to install a Carbon Event handler for >>the {kEventClassApplication, kEventAppFrontSwitched} event. > >If you don't mind asking your users to switch on accessibility access ("enable >access for assistive devices" in the Universal Access preferences), you can >use the Accessibility APIs to monitor app switching (this is what's used in >the iChatStatusFromApplication sample code, for example - >http://developer.apple.com/samplecode/iChatStatusFromApplication/). I'm using accessibility for other purposes too, so that's the first thing I tried. The restriction on that is that you have to register for each application you need to watch, it's not a general notification. It also means you have to use other notifications to watch for applications to start up and quit, keep a list of running applications, etc. Lots of overhead and opportunities to go wrong. For completeness, I'd like to mention that you don't need to ask the user to switch on accessibility if you use the APIs from a background process that's been authorized via AXMakeProcessTrusted(). >I say this informationally - I don't think it's a great solution either. Exactly. -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/bb/viewtopic.php ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Moving oneself to /Applications (or ~/Applications)
At 03:06 -0800 24/02/09, cocoa-dev-requ...@lists.apple.com wrote: >From: Tommy Nordgren >References: <67c1da73-c3cb-4854-9b46-70c0365d5...@mac.com> > <57b2a86d-b87c-486f-8d2e-6291d3f29...@comhem.se> > <4b898f01-2234-4d19-8b63-25f4cd275...@webis.net> > <15c43c09-ae0d-455e-ae10-5bc8c2714...@comhem.se> > >In-Reply-To: >Date: Tue, 24 Feb 2009 04:08:36 +0100 >Message-ID: <8d535551-d24a-47ad-8fa2-2138ca7ec...@comhem.se> > >On Feb 24, 2009, at 3:34 AM, Shawn Erickson wrote: > >>On Mon, Feb 23, 2009 at 6:22 PM, Tommy Nordgren >> wrote: >>>The following code will test if you are running from the DMG: >>> >>>NSString * volName = @"Mother"; >>>NSString * appName = @"MyApp.app"; >>> >>>if ([[[NSBundle mainBundle] bundlePath] isEqualTo: [ NSString >>>stringWithFormat:@"/Volumes/%@/%@",volName,appName]) { >>> >>> //Here you can show an alert telling the user to to copy the app to >>>the applications folder >>> >>>} >> >>If a disk image it mounted a second time (can happen in a few ways) it >>won't be at /Volumes/Mother/... but at /Volumes/Mounter 1/... Also you >>can mount disk images in location other then under /Volumes/... > It will be /Volumes/Mother 1/... I've tested. >This can be handled by using a regexp class for the matching instead of a >simple >equality test. > Also, while it's possible to mount a disk image at other places than > under Volumes, >that won't happen when doubleclicking a disk image or it being mounted from >Safari You might want to look at http://www.brockerhoff.net/src/index.html scroll down to "PathProps". It's source code I wrote to check volume/device parameters for a given path; the original idea was to check whether your app is running from a disk image. (Some of the code to find out details for a network volume calls deprecated API's; you might want to comment that out.) In fact, I don't recommend using this code directly; use parts and modify as you see fit. For one, if your app is in ~/Applications and the user is using FileVault, the home folder _will_ be on a disk image. So you'll also have to check if the volume is read-only r not. It may be useful to also distinguish whether you're running from a generic disk image or optical disk, or specifically from _your_ distribution disk image. For that, I found it most useful to have a hidden file next to my app on the original image. This hidden file has a name like ".29E04275-96F1-4CF5-9EB5-4ECE6908C460.png" (make your own UUID in the Terminal typing "uuidgen"), and doubles as the disk image's hidden background image. Then I simply check for the presence of this file. What action to take depends on what your software does. If you have to install a launch agent or setuid/setgid tool, these binaries won't work properly from FileVault or on a disk image, so you pretty much have to handle this case. Personally I avoid installer packages - I've lost data in the past by improperly quoted folder paths in installer scripts, and dislike writing shell scripts myself. An alternative is to do a one-time check; have a "first run" key in your preferences, and if the user is running from the dmg, you offer to copy the application. Previous posts have discussed the problem of "moving" a running application. This is actually unnecessary. You can copy your entire application bundle with an API like FSPathCopyObjectSync() or one of the Cocoa equivalents, start the copy with LaunchServices, quit, and have the copy unmount the disk image. While I'm not sure I was the first to use the symlink-to-Applications technique, I started using it in 2003 (see http://db.tidbits.com/article/8357). If you use it, be sure to use a symlink instead of a Finder-generated alias file; besides being larger, an alias may contain private data about your home system, like the name and creation timestamp of your boot drive. Downside of the symlink idea is that there's no way to make a generic symlink to ~/Applications. HTH, -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/bb/viewtopic.php ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Conditional mouseDownCanMoveWindow for NSView?
At 12:03 -0700 02/10/08, [EMAIL PROTECTED] wrote: >From: "Daniel Weber" <[EMAIL PROTECTED]> >Date: Thu, 2 Oct 2008 11:15:40 -0700 >Message-ID: <[EMAIL PROTECTED]> > >I have a single nsview that draws the main content area for my application >and a bottom statusbar. This was done instead of using two different views >so the user can move objects from the statusbar to the main content area, >all with core animation effects. The view is not opaque. The problem I'm >having, though, is that I want the user to be able to drag the window when >the mouse is down on the statusbar, but not the main content area. In other >words, if the mousedown is within the statusbar's rectangle I want to return >YES for mouseDownCanMoveWindow. But if the mousedown is within the main >content area rectangle, I want to return NO. I have already tried setting a >flag in the mouseDown method and then returning that >in mouseDownCanMoveWindow. But it doesn't work. I guess mouseDown is not >called before mouseDownCanMoveWindow. Anyway, does anyone have any other >suggestions for this? I had that very same problem in RBSplitView. The only solution I found is to always return NO in mouseDownCanMoveWindow, then move the window "manually" inside mouseDown like this: - (void)mouseDown:(NSEvent*)theEvent { NSWindow* window = [self window]; NSPoint where = [theEvent locationInWindow]; if (...test for your rect here...) { where = [window convertBaseToScreen:where]; NSPoint origin = [window frame].origin; // Now we loop handling mouse events until we get a mouse up event. while ((theEvent = [NSApp nextEventMatchingMask:NSLeftMouseDownMask|NSLeftMouseDraggedMask|NSLeftMouseUpMask untilDate:[NSDate distantFuture] inMode:NSEventTrackingRunLoopMode dequeue:YES])&&([theEvent type]!=NSLeftMouseUp)) { // Set up a local autorelease pool for the loop to prevent buildup of temporary objects. NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSPoint now = [window convertBaseToScreen:[theEvent locationInWindow]]; origin.x += now.x-where.x; origin.y += now.y-where.y; // Move the window by the mouse displacement since the last event. [window setFrameOrigin:origin]; where = now; [pool release]; } } } -- Rainer Brockerhoff <[EMAIL PROTECTED]> Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/bb/viewtopic.php ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Drag Tabs, Custom Colors
At 17:21 -0800 11/11/08, [EMAIL PROTECTED] wrote: >From: "Kyle Sluder" <[EMAIL PROTECTED]> >References: <[EMAIL PROTECTED]> >In-Reply-To: <[EMAIL PROTECTED]> >Date: Tue, 11 Nov 2008 19:23:58 -0500 >Message-ID: <[EMAIL PROTECTED]> > >> 2. Is there any "easy" way to customize the colors used by Cocoa's controls >> to use neutral grays, like Apple's pro apps? > >No. Well, you can use the standard way to override some global preference just for your app: int main(int argc, char *argv[]) { [[NSUserDefaults standardUserDefaults] setVolatileDomain: [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:NSGraphiteControlTint] forKey:@"AppleAquaColorVariant"] forName:NSRegistrationDomain]; return NSApplicationMain(argc, (const char **) argv); } For this specific key, it must be done before calling NSApplicationMain(). It works, but this is sort of a gray (hehe) area. The key "AppleAquaColorVariant" is undocumented. It's not too likely to change, but if it changes, your control color will return to normal with no other harm done - no crashing etc. Use at your own risk. HTH, -- Rainer Brockerhoff <[EMAIL PROTECTED]> Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/bb/viewtopic.php ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: need advice on subclassing NSScrollVIew
At 19:59 -0700 19/03/09, cocoa-dev-requ...@lists.apple.com wrote: >From: John Reppy >Date: Thu, 19 Mar 2009 15:39:44 -0500 >Message-ID: > >I'm building a viewer for event logs that needs to support a wide range >of scales (say from seconds/inch to nanoseconds/inch). I've got a custom >subclass of NSView for displaying this information, which I want to embed >in an NSScrollView. The problem that I'm faced with is that the floating-point >coordinates used by Cocoa do not have enough precision at full magnification. > >I'm guessing that the best solution is to subclass NSScrollView to track the >visible rectangle's origin using doubles, but I'm not sure which NSScrollView >methods I should be overriding. Also, do I need to override NSClipView too? >Any pointers or suggestions would be appreciated. In a similar situation, I didn't subclass NSScrollView. I subclassed NSView and inserted an NSScroller directly as its subview. I tracked the position with a 64-bit variable which I converted to a range suitable for the NSScroller just for setting its thumb position and size. I set my view as the NSScroller's target to convert back to my 64-bit position. In the subclass' -drawRect: method, I calculated the visible portion of the view, and simply drew that - no NSClipView required. For your case, you'd have an additional step involving the scale; be careful with loss of precision there. Despite being somewhat more work to implement, this proved to be more efficient and also a good learning experience regarding the view drawing mechanism. HTH, -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/bb/viewtopic.php ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Change view on resize
At 05:46 -0700 10/04/09, cocoa-dev-requ...@lists.apple.com wrote: >From: Graham Cox >References: <20090410073454.0145819aa2...@lists.apple.com> > <8bc5d931-c976-4670-987e-90da25217...@mac.com> >In-Reply-To: <8bc5d931-c976-4670-987e-90da25217...@mac.com> >Date: Fri, 10 Apr 2009 21:41:28 +1000 >Message-ID: <5b72d110-ce92-4f63-b173-055ae...@bigpond.com> > >On 10/04/2009, at 9:32 PM, Gregory Weston wrote: > >>To the OP: Please put a *lot* of thought into whether you really need to do >>this. Despite the fact that a couple of Apple applications deviate from the >>semantics of the zoom button it's extremely non-standard behavior. Even if >>you do it well and to good effect (like iTunes, IMO) you'll irritate a lot of >>users. The fact that Calculator alters the meaning of a button that most >>users (wrongly) think is supposed to toggle between full screen and "where I >>set it" to effectively change itself into a completely different app (beyond >>the baseline notion of 'calculator') is just ... blech. > > >I never noticed Calculator did this until this thread came up. While it's >certainly sort of handy, it's *very* non-standard. On the other hand it's not >unprecedented, iTunes overloads the zoom button similarly, and far more >annoyingly since the normal meaning of zoom could apply within iTunes and >making it full screen or maximised has to be done by dragging. While implementing Klicko's window maximizing behavior, at first I noticed that iTunes didn't respond at all to the Accessibility command to set window size. However, since version 8 (I think), it does; also, option-clicking on the Zoom button now resizes the iTunes window to an "optimum" size. There's still no menu equivalent though... -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/bb/viewtopic.php ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: String Comparison and return values
At 01:06 -0700 26/05/09, cocoa-dev-requ...@lists.apple.com wrote: >From: Thomas Davie >To: John Ku >References: > <298ad53c-ec5e-4519-bbba-61a13ca9c...@bigpond.com> > > > <7e0b7c90-a346-431f-8220-c8eccafd9...@mac.com> > >In-Reply-To: >Date: Tue, 26 May 2009 10:04:15 +0200 >Message-ID: <11f773a4-ad73-423c-847a-2d5fa8f80...@gmail.com> > >Op 26 May 2009, om 09:56 heeft John Ku het volgende geschreven: > >>Oh so the very first return value from a Dictionary is not actually a >>string? >>NSString *itemA = [DictionaryA valueForKey:@"FirstProcessIdentifier"]; >> >>I've check the apple document, valueForKey returns an ID... so it return an >>object? how do I proceed? >>If i cast it as NSString it gives me an error. > >Simple - sort your type error out! The dictionary contains at least one >number. This means that either you're creating it wrong, or you're trying to >get values out of it wrong... > >In the latter case you might want to try something like > >id item = [dictionaryA valueForKey:@"FirstProcessIdentifier"]; > >if ([item isKindOfClass:[NSString class]]) >{ > // do stuff >} >else if ([item isKindOfClass:[NSNumber class]]) >{ > // do other stuff >} >... It appears that one of the items can be an NSString and the other an NSNumber, so none of the standard comparisons will work directly. Instead of testing what kind of class each is, I'd try something like if ([itemA intValue] == [itemB intValue]) ... since both NSString and NSNumber will respond to intValue, that should work. -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/bb/viewtopic.php ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Creating a NSView with Interface Builder
At 18:24 -0800 25/02/08, [EMAIL PROTECTED] wrote: >From: Herr Thomas Bartelmess <[EMAIL PROTECTED]> >Date: Mon, 25 Feb 2008 22:41:25 +0100 >Message-ID: <[EMAIL PROTECTED]> > >i'm currently working on a Plugin. My problem is that i have to provide a >preference View. I have to give a NSView to the programm. Currently i wrote a >NSView Subclass, but its to much work to do every button an textfield by code. >My question is, how can I design an View in Interface Builder an give the >result as an NSView to an other object. Thomas, Somewhat late to this thread, but if you go to http://www.brockerhoff.net/pap.html and download the first paper in the list ("Plugged-In Cocoa"), you'll see detailed instructions and a sample project. It's from 2002 but everything should still work. Gut Glück, -- Rainer Brockerhoff <[EMAIL PROTECTED]> Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." Weblog: http://www.brockerhoff.net/bb/viewtopic.php ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Alternative to NSRunningApplication launchDate?
On 8/1/14, 14:33, cocoa-dev-requ...@lists.apple.com wrote: Date: Thu, 31 Jul 2014 15:46:21 -0400 From: Sean McBride Subject: Alternative to NSRunningApplication launchDate? Message-ID: <20140731194621.1455233...@mail.rogue-research.com> Content-Type: text/plain; charset=ISO-8859-1 The docs for NSRunningApplication launchDate say "only available for applications that were launched by LaunchServices." And indeed if the app was launched by Xcode (for debugging) launchDate returns nil. Anyone know another way of finding an app's launch date? Some UNIX layer API? The old Process Manager APIs - specifically, GetProcessPID(), GetNextProcess() and GetProcessInformation() - do what you want; they were deprecated in 10.9 but still work on 10.10. And, as far as I know, no substitute API has been announced yet. HTH, -- Rainer Brockerhoff Belo Horizonte, Brazil "In the affairs of others even fools are wise In their own business even sages err." http://brockerhoff.net/blog/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com