• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: PDFView drawPage called often after selecting text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PDFView drawPage called often after selecting text


  • Subject: Re: PDFView drawPage called often after selecting text
  • From: Martin Hewitson <email@hidden>
  • Date: Tue, 08 Jan 2013 12:59:28 +0100

On Jan 8, 2013, at 09:21 AM, Kyle Sluder <email@hidden> wrote:

> On Jan 7, 2013, at 9:16 AM, Martin Hewitson <email@hidden> wrote:
>
>>
>> On 7, Jan, 2013, at 05:52 PM, Kyle Sluder <email@hidden> wrote:
>>
>>> On Jan 7, 2013, at 2:48 AM, Martin Hewitson <email@hidden> 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....
>
> I'm still not sure this is a good approach to take.
>
> The drawing machinery is pretty optimized. It's easy to do unsafe things that behave perfectly fine in certain limited circumstances t have deleterious effects in others.
>
> Locking focus on your superview while you're in the middle of a lockFocus operation strikes me as one of those unsafe things that might usually work until it doesn't.
>
> Is there any particular reason you can't use the old -setKeyboardFocusRingNeedsDisplayInRect: method and draw your focus ring in your own graphics context in -drawRect:?

Maybe not. I just didn't know about this, but I will read up on it. However, as far as my tests show, -drawRect: is never called on PDFView.

Cheers,

Martin

>
> --Kyle Sluder






_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: PDFView drawPage called often after selecting text
      • From: Andy Lee <email@hidden>
References: 
 >PDFView drawPage called often after selecting text (From: Martin Hewitson <email@hidden>)
 >Re: PDFView drawPage called often after selecting text (From: Martin Hewitson <email@hidden>)
 >Re: PDFView drawPage called often after selecting text (From: Kyle Sluder <email@hidden>)
 >Re: PDFView drawPage called often after selecting text (From: Martin Hewitson <email@hidden>)
 >Re: PDFView drawPage called often after selecting text (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: Printing layer-based view
  • Next by Date: [MEET] CocoaHeadsNYC this Thursday, January 10
  • Previous by thread: Re: PDFView drawPage called often after selecting text
  • Next by thread: Re: PDFView drawPage called often after selecting text
  • Index(es):
    • Date
    • Thread