Zooming Breaks Focus-ring Architecture (10.13.1)
Dear Cocoa-dev People, The main view of my app can be zoomed by the user. It contains NSTextView subviews. The NSTextView focus-rings are well-drawn when the main view is not zoomed. But when it is zoomed, focus rings are not drawn properly. They are drawn the same size, no matter what the zoom factor. And they drift downward as zoom is increased. Note that the text fields themselves are zoomed properly and all mouse clicks are interpreted correctly in zoomed views; just the focus-rings are wrong. Am I doing something wrong? Is there any way to get zoomed focus rings to work using the Cocoa focus ring APIs? Thanks, Joel Norvell This describes my zoom-architecture: // "self" is an NSImageView subclass containing NSTextViews as subviews. - (void) doZoom:(float)scale { float width = [[self bounds].width; float height = [[self bounds].height; NSRect zoomedRect = NSMakeRect(0, 0, width*scale, height*scale*pages); NSRect boundsRect = NSMakeRect(0, 0, width, height*pages); // Make view corners have integral values. zoomedRect = [self roundedRect:zoomedRect]; [self setFrame:zoomedRect]; [self setBounds:boundsRect]; [self setNeedsDisplay:YES]; [self scrollToTop]; } // "self" is an NSTextField nested in the NSImageView subclass. // Part of initialization pertinent to focus-rings // N.B. My NSTextField subclass doesn't use or explicitly do anything to opt-into Core Animation layers. - (void) initTextField; { [self setFocusRingType:NSFocusRingTypeExterior]; [self setDrawsBackground:NO]; [[self cell] setRefusesFirstResponder:NO]; // accept 1st responder. [[self cell] setShowsFirstResponder: YES]; } If I use Apple's focus-ring APIs, the focus-ring is drawn as if the text-view has not been zoomed. And it is shifted downward from it's correct location. - (void)drawFocusRingMask { // Set the focus ring mask to the zoomed bounds. NSRectFill([self focusRingMaskBounds]); } - (NSRect)focusRingMaskBounds { return [self bounds]; } ___ 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: NSString equivalent of CFSTR macro?
> On Dec 4, 2017, at 16:14 , Greg Parker wrote: > > >> On Dec 4, 2017, at 3:22 PM, Rick Mann wrote: >> >> Ugh...been doing too much Swift (j/k). The right answer to this question is: >> >> @(kSomeCStringConstant) >> >> This works whether it's a #define or a static const char* const. > > The downsides are: > 1. If the library requires that you use the actual address stored in string > variable kSomeCStringConstant then it may fail because > @(kSomeCStringConstant) may create a second object at a different address. > 2. The compiler is not currently smart enough to optimize > @(kSomeCStringConstant) into a constant string object, so it may allocate a > new autoreleased string object every time it runs that line. Yeah, I figured as much. In this case, that's okay. I was just trying to declutter the call site. Thanks! -- Rick Mann rm...@latencyzero.com ___ 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: NSString equivalent of CFSTR macro?
> On Dec 4, 2017, at 3:22 PM, Rick Mann wrote: > > Ugh...been doing too much Swift (j/k). The right answer to this question is: > > @(kSomeCStringConstant) > > This works whether it's a #define or a static const char* const. The downsides are: 1. If the library requires that you use the actual address stored in string variable kSomeCStringConstant then it may fail because @(kSomeCStringConstant) may create a second object at a different address. 2. The compiler is not currently smart enough to optimize @(kSomeCStringConstant) into a constant string object, so it may allocate a new autoreleased string object every time it runs that line. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ 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: NSString equivalent of CFSTR macro?
Ugh...been doing too much Swift (j/k). The right answer to this question is: @(kSomeCStringConstant) This works whether it's a #define or a static const char* const. > On Dec 4, 2017, at 15:00 , Greg Parker wrote: > > >> On Dec 4, 2017, at 2:56 PM, Rick Mann wrote: >> >>> On Dec 4, 2017, at 14:55 , Greg Parker wrote: >>> On Dec 4, 2017, at 2:51 PM, Ben Kennedy wrote: > On Dec 4, 2017, at 2:47 PM, Rick Mann wrote: > > #define NSSTR(s) (@ ## s) <-- magic; this > doesn't work > #define kSomeCStringConstant "foo" > ... > NSSTR(kSomeCStringConstant) You're close. The preprocessor is removing the quotation marks, breaking the syntax. You don't need to token paste; simply remove the '##' from the NSSTR() def. #define NSSTR(s) (@ s) >>> >>> You can also skip the middleman and use `@kSomeCStringConstant`. After the >>> preprocessor runs it will be `@"foo"` which the ObjC compiler is perfectly >>> happy with. >> >> Tried that, too. Same error: >> >> MCP.m:262:54: Unexpected '@' in program > > What compiler version are you using? > Is this file compiled as Objective-C? > Is the #define spelled differently than you wrote? > Does anything look wrong with that line in the output of Product > Perform > Action > Preprocess ? > > > -- > Greg Parker gpar...@apple.com Runtime Wrangler > > -- Rick Mann rm...@latencyzero.com ___ 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: NSString equivalent of CFSTR macro?
> On Dec 4, 2017, at 2:56 PM, Rick Mann wrote: > >> On Dec 4, 2017, at 14:55 , Greg Parker wrote: >> >>> On Dec 4, 2017, at 2:51 PM, Ben Kennedy wrote: >>> On Dec 4, 2017, at 2:47 PM, Rick Mann wrote: #define NSSTR(s) (@ ## s) <-- magic; this doesn't work #define kSomeCStringConstant "foo" ... NSSTR(kSomeCStringConstant) >>> >>> You're close. The preprocessor is removing the quotation marks, breaking >>> the syntax. You don't need to token paste; simply remove the '##' from the >>> NSSTR() def. >>> >>> #define NSSTR(s) (@ s) >> >> You can also skip the middleman and use `@kSomeCStringConstant`. After the >> preprocessor runs it will be `@"foo"` which the ObjC compiler is perfectly >> happy with. > > Tried that, too. Same error: > > MCP.m:262:54: Unexpected '@' in program What compiler version are you using? Is this file compiled as Objective-C? Is the #define spelled differently than you wrote? Does anything look wrong with that line in the output of Product > Perform Action > Preprocess ? -- Greg Parker gpar...@apple.com Runtime Wrangler ___ 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: NSString equivalent of CFSTR macro?
Ah, nvm, user error. I'm an idiot. It's not a #defined string. It's: static const char* const kSomeCStringConstant = "foo"; > On Dec 4, 2017, at 14:56 , Ben Kennedy wrote: > > On Dec 4, 2017, at 2:53 PM, Rick Mann wrote: > >> I tried that. It doesn't work. >> >> MCP.m:262:54: Unexpected '@' in program > > Weird. I just tried it here, using your exact example, and it worked fine > under Xcode 9.2. (I slapped it into my iOS app's > application:didFinishLaunchingWithOptions: as a quick and dirty test.) > > #define NSSTR(s)(@ s) > #define kSomeCStringConstant"foo" > NSLog(@"foo is %@", NSSTR(kSomeCStringConstant)); > > Do you have some unusual circumstances in your build environment? > > b > -- Rick Mann rm...@latencyzero.com ___ 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: NSString equivalent of CFSTR macro?
> On Dec 4, 2017, at 14:55 , Greg Parker wrote: > > >> On Dec 4, 2017, at 2:51 PM, Ben Kennedy wrote: >> >>> On Dec 4, 2017, at 2:47 PM, Rick Mann wrote: >>> >>> #define NSSTR(s)(@ ## s) <-- magic; this >>> doesn't work >>> #define kSomeCStringConstant"foo" >>> ... >>> NSSTR(kSomeCStringConstant) >> >> You're close. The preprocessor is removing the quotation marks, breaking the >> syntax. You don't need to token paste; simply remove the '##' from the >> NSSTR() def. >> >> #define NSSTR(s) (@ s) > > You can also skip the middleman and use `@kSomeCStringConstant`. After the > preprocessor runs it will be `@"foo"` which the ObjC compiler is perfectly > happy with. Tried that, too. Same error: MCP.m:262:54: Unexpected '@' in program > > > -- > Greg Parker gpar...@apple.com Runtime Wrangler > > -- Rick Mann rm...@latencyzero.com ___ 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: NSString equivalent of CFSTR macro?
On Dec 4, 2017, at 2:53 PM, Rick Mann wrote: > I tried that. It doesn't work. > > MCP.m:262:54: Unexpected '@' in program Weird. I just tried it here, using your exact example, and it worked fine under Xcode 9.2. (I slapped it into my iOS app's application:didFinishLaunchingWithOptions: as a quick and dirty test.) #define NSSTR(s)(@ s) #define kSomeCStringConstant"foo" NSLog(@"foo is %@", NSSTR(kSomeCStringConstant)); Do you have some unusual circumstances in your build environment? b ___ 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: NSString equivalent of CFSTR macro?
> On Dec 4, 2017, at 2:51 PM, Ben Kennedy wrote: > >> On Dec 4, 2017, at 2:47 PM, Rick Mann wrote: >> >> #define NSSTR(s) (@ ## s) <-- magic; this >> doesn't work >> #define kSomeCStringConstant "foo" >> ... >> NSSTR(kSomeCStringConstant) > > You're close. The preprocessor is removing the quotation marks, breaking the > syntax. You don't need to token paste; simply remove the '##' from the > NSSTR() def. > > #define NSSTR(s) (@ s) You can also skip the middleman and use `@kSomeCStringConstant`. After the preprocessor runs it will be `@"foo"` which the ObjC compiler is perfectly happy with. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ 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: NSString equivalent of CFSTR macro?
I tried that. It doesn't work. MCP.m:262:54: Unexpected '@' in program > On Dec 4, 2017, at 14:51 , Ben Kennedy wrote: > >> On Dec 4, 2017, at 2:47 PM, Rick Mann wrote: >> >> #define NSSTR(s) (@ ## s) <-- magic; this >> doesn't work >> #define kSomeCStringConstant "foo" >> ... >> NSSTR(kSomeCStringConstant) > > You're close. The preprocessor is removing the quotation marks, breaking the > syntax. You don't need to token paste; simply remove the '##' from the > NSSTR() def. > > #define NSSTR(s) (@ s) > > -b > -- Rick Mann rm...@latencyzero.com ___ 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: NSString equivalent of CFSTR macro?
> On Dec 4, 2017, at 2:47 PM, Rick Mann wrote: > > #define NSSTR(s) (@ ## s) <-- magic; this > doesn't work > #define kSomeCStringConstant "foo" > ... > NSSTR(kSomeCStringConstant) You're close. The preprocessor is removing the quotation marks, breaking the syntax. You don't need to token paste; simply remove the '##' from the NSSTR() def. #define NSSTR(s) (@ s) -b ___ 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
NSString equivalent of CFSTR macro?
I have to use some C header file that #defines some string constants. Is there an equivalent to CFSTR() that constructs NSString literals? E.g., #define NSSTR(s)(@ ## s) <-- magic; this doesn't work #define kSomeCStringConstant"foo" ... NSSTR(kSomeCStringConstant) TIA, -- Rick Mann rm...@latencyzero.com ___ 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: Stopping on a system call and determining open files?
It dawned on me that it was probably getting bad data from the network. My friend (who works on iTunes servers) fixed it on the server side, and that's why the problem went away (although hopefully they update the client code to be more robust. I bet if this were written in Swift, this particular error wouldn't have happened). > On Dec 3, 2017, at 19:41 , Richard Charles wrote: > > >> On Dec 3, 2017, at 8:16 PM, Jerome Krinock wrote: >> >>> On 2017 Dec 1, at 21:54, Rick Mann wrote: >>> >>> Certificate Key (CK) >> >> The stack trace in your first post indicates that CK is more likely >> CommerceKit. For example: >> >>> On 2017 Dec 1, at 21:15, Rick Mann wrote: >>> >>> 5 CommerceKit 0x7fff5a62d858 -[CKStoreDAAPLibrary >>> _writePersistedStore] + 402 > > > CommerceKit trying to write out some sort of iTunes Digital Audio Access > Protocol (DAAP) file. > > --Richard Charles > > ___ > > 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/rmann%40latencyzero.com > > This email sent to rm...@latencyzero.com -- Rick Mann rm...@latencyzero.com ___ 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