Re: setting selection in PDFView
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