Re: Missing Mouse Events in PDFView
Re: Missing Mouse Events in PDFView
- Subject: Re: Missing Mouse Events in PDFView
- From: Alexander Griekspoor <email@hidden>
- Date: Wed, 31 Oct 2007 18:36:48 +0000
Thanks, that certainly helps. I wasn't aware that now the mouseDown
method only exits on a mouseUp. The solution would be simple then
indeed.
Great!
Ps. the Leopard PDFView rocks...
On 31-okt-2007, at 17:47, John Calhoun wrote:
On Oct 31, 2007, at 3:51 AM, Alexander Griekspoor wrote:
Is it me or does it no longer work to subclass mouse events in
PDFView?
It's not you.
I didn't realize this would break anyone....
Most of AppKit in fact don't use the -[mouseDragged] and -[mouseUp]
events for tracking. As of Leopard, neither does PDF Kit.
It turns out that, for tracking in any event, a lot of state has to
be kept (instance vars) in order to handle dragging or tracking
across the three event flavors. So what PDF Kit does now is:
// Track the mouse while down.
while ((nextEvent = [[self window] nextEventMatchingMask:
NSLeftMouseDraggedMask | NSLeftMouseUpMask]))
{
NSPoint viewMouse;
NSPoint pageMouse;
// Get mouse in page coordinates.
viewMouse = [self convertPointFromBase: [nextEvent
locationInWindow]];
pageMouse = [self convertPoint: viewMouse toPage: page];
// Handle mouse tracking.
// When the mouse is let up, we are done.
if ([nextEvent type] == NSLeftMouseUp)
{
// Break out of mouse tracking loop.
break;
}
}
PDF Kit may have a bug though since I would nonetheless expect you
to get your mouse up event. I'm thinking PDF Kit is swallowing the
mouse up event in it's while loop (above).
A workaround might be to subclass mouseDown and post your own
mouseUp event at the tail of your method after calling -[super
mouseDown:] if on Leopard.
Does this help?
I apologize again for not anticipating this.
john calhoun—
*********************************************************
** Alexander Griekspoor PhD **
*********************************************************
EMBL Outstation - Hinxton,
European Bioinformatics Institute,
Rebholz Textmining group
Wellcome Trust Genome Campus,
Cambridge, CB10 1SD, UK
Tel: + 44 1223 492 605
Fax: + 44 1223 492 468
Web: http://www.mekentosj.com
Papers - Your Personal Library of Science
2007 Winner of the Apple Design Awards
Best Mac OS X Scientific Solution
http://www.mekentosj.com/papers
*********************************************************
_______________________________________________
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