Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Missing Mouse Events in PDFView



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—

_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Missing Mouse Events in PDFView (From: Alexander Griekspoor <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.