On 7, Jan, 2013, at 05:52 PM, Kyle Sluder <k...@ksluder.com> wrote:

> On Jan 7, 2013, at 2:48 AM, Martin Hewitson <martin.hewit...@aei.mpg.de> 
> wrote:
> 
>> Actually, at the risk of having a conversation with myself, I've narrowed 
>> the issue down to the actions I'm taking within my override of -drawPage:. 
>> Essentially what I'm aiming at is having a focus ring on the PDFView. I do 
>> this in my PDFView subclass:
>> 
>> - (void)drawPage:(PDFPage *)page {
>> [super drawPage:page];
>> // focussed?
>> if ([[self window] firstResponder] == self && [NSApp isActive]) {    
>>   [[self superview] lockFocus];
>>   NSRect fr = [self frame];
>>   NSSetFocusRingStyle(NSFocusRingOnly);
>>   [[NSBezierPath bezierPathWithRect:fr] fill];
>>   [[self superview] unlockFocus];
>> }
>> }
> 
> This sounds extremely iffy to me. You're dirtying regions of your window that 
> overlap other views in the middle of a recursive -drawRect:. I'm surprised 
> this doesn't crash or spin infinitely.

This solution was advised on this list (see thread "PDFView focus ring" from 
Feb 2012), but it certainly doesn't seem to play nicely with my app. What's 
strange is that it doesn't cause problems in a very basic test app....

> 
>> 
>> Is there perhaps a better way I can achieve this focus ring without 
>> triggering this (recursive?) -drawPage: behaviour?
> 
> Why not use the modern API, -noteFocusRingMaskChanged and -drawFocusRingMask?

Unfortunately I want to maintain support for 10.6.8 and these only appear in 
10.7, as far as I can tell.

Cheers,

Martin

> 
> --Kyle Sluder



_______________________________________________

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

Reply via email to