• 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: How to get deviceDeltaX/Y from NSScrollWheel..?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get deviceDeltaX/Y from NSScrollWheel..?


  • Subject: Re: How to get deviceDeltaX/Y from NSScrollWheel..?
  • From: Elmar Krieger <email@hidden>
  • Date: Thu, 01 Feb 2007 23:45:07 +0100

Thanks for all the off-list feedback, I'm posting the solution for Google reference:

My event loop receives NSScrollWheel events, most of which have deltaX/Y/Z all at 0. I assume these contain the high precision scrolling data. But how can I get it?

Apple describes the solution for Carbon only: http://developer.apple.com/qa/qa2005/qa1453.html

For Cocoa, you need to add declarations that are currently missing in the file
/System/Library/Frameworks/AppKit.framework/Versions/C/Headers/NSEvent.h

The 'root password solution' is to add them there directly, after

- (float)deltaX;
- (float)deltaY;
- (float)deltaZ;        // 0 for most scroll wheel and mouse events

insert these two lines:

- (float)deviceDeltaX;
- (float)deviceDeltaY;


The 'soft solution' (thanks Hidetomo Katsura!) is to add this to your code:

@interface NSEvent (DeviceDelta)
  - (float)deviceDeltaX;
  - (float)deviceDeltaY;
@end


Then you can get the smooth scroll events:

NSEvent *event;
float dx, dy;

dx = [ event deviceDeltaX ];
dy = [ event deviceDeltaY ];


Hope that saves someone's day ;-)

Elmar



The posting below mentions deviceDeltaX/Y methods, which should match the Carbon parameters kEventParamMouseWheelSmoothVertical/HorizontalDelta in the kEventMouseScroll Carbon event:


http://lists.apple.com/archives/carbon-dev/2005/Nov/msg01070.html

But a "grep -r deviceDelta *" in directory /System/Library/Frameworks finds only binaries, but no header files. So deviceDeltaX/Y doesn't seem to be declared anywhere...?

Thanks for your help,
Elmar
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


References: 
 >How to get deviceDeltaX/Y from NSScrollWheel..? (From: Elmar Krieger <email@hidden>)

  • Prev by Date: Re: Strange stretching NSView
  • Next by Date: Re: what is error -7000 when activating fonts?
  • Previous by thread: How to get deviceDeltaX/Y from NSScrollWheel..?
  • Next by thread: How to get deviceDeltaX/Y from NSScrollWheel..?
  • Index(es):
    • Date
    • Thread