• 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: setting selection in PDFView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: setting selection in PDFView


  • Subject: Re: setting selection in PDFView
  • From: Markus Spoettl <email@hidden>
  • Date: Fri, 20 Jul 2012 19:13:08 +0200

On 7/20/12 6:28 PM, Martin Hewitson wrote:
Dear list,

In my app I have a user action which allows them to select a particular line in a PDFView. The relevant method (on my PDFView subclass) looks like this.

- (void)displayLineAtPoint:(NSPoint)point inPageAtIndex:(NSUInteger)pageIndex
{
   if (pageIndex < [[self document] pageCount]) {
     [[self window] makeFirstResponder:self];
     PDFPage *page = [[self document] pageAtIndex:pageIndex];
     PDFSelection *sel = [page selectionForLineAtPoint:point];
     [self performSelectorOnMainThread:@selector(goToPage:) withObject:page waitUntilDone:YES];
     [self setCurrentSelection:sel];
     [self scrollSelectionToVisible:self];
     [self display];
     [self setCurrentSelection:nil];
     [self performSelector:@selector(setCurrentSelectionAndAnimate:) withObject:sel afterDelay:0.2];
   }
}

[self performSelectorOnMainThread:@selector(goToPage:) withObject:page waitUntilDone:YES];

looks suspicious. If you're doing this on a secondary thread (which this line implies), I'm pretty sure that at least the call to -makeFirstResponder: is illegal (main thread only). Not sure about the PDF document class.

Regards
Markus
--
__________________________________________
Markus Spoettl
_______________________________________________

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

  • Prev by Date: Re: Sharing a file between Mac and iOS
  • Next by Date: Re: Icon Overlay on Mac OSX
  • Previous by thread: Using RBSplitView or BWSplitView programmatically
  • Next by thread: Re: setting selection in PDFView
  • Index(es):
    • Date
    • Thread