OSX's scrolling direction


#1

Hi Jules,

In Lion, there’s that new (so-called) ‘natural scrolling direction’ for trackpad.
The problem is that when controlling sliders thru trackpad, the fader’s action it’s reversed : scrolling up lowers the slider and vice versa.
A ‘scrolling direction’ option would be handy (and save some brain sanity) !

Salvator


#2

Yes, I’ve been meaning to do something about that…

Not sure what’s the correct approach though. Perhaps the whole mouseWheelMove() callback needs to be overhauled to provide a more useful structure as its argument, which could provide extra info like whether the wheel is reversed, whether there are both a vertical and horizontal wheels present, etc. Then things like the slider could make smarter decisions. Would require a lot of people changing their code though…


#3

Ah ! I thought default arguments would avoid too much change in user’s code…
Personally though, I don’t mind changing things in my code for this.

Salvator


#4

It’s one of those things I wish I’d done differently years ago when I originally created the method. But yes, it’s probably worth causing some inconvenience to people to make it future-proof.


#5

Cool,

It works ! Thanks,
for anybody interested : it’s easy to implement without changing much in user’s code, by keeping local float and assigning wheel.deltaX/Y to that local float :

float wheelIncrementY;    
float wheelIncrementX; 
 wheel.isReversed ? wheelIncrementX = - wheel.deltaX : wheelIncrementX = wheel.deltaX;
 wheel.isReversed ? wheelIncrementY = - wheel.deltaY : wheelIncrementY = wheel.deltaY;

Salvator


#6

In juce_mac_NSViewComponentPeer.mm there’s a tiny issue :

const float scale = 0.5f / 256.0f;
is declared inside #if defined (MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
But it’s also used after the #endif, and this cause a ‘scale not declared’ problem in my case.
Moving declaration prior the definition fix it.

Salvator


#7

Thanks, I already fixed that scale thing.

…ouch… Assignments inside conditional statement expressions, really!?


#8

what about :

wheelIncrementX = (wheel.isReversed ? - wheel.deltaX : wheel.deltaX); wheelIncrementY = (wheel.isReversed ? - wheel.deltaY : wheel.deltaY); Salvator


#9

Much better!


#10

Sorry again to bother with this, but the fix work only for 10.7 SDK here.
While compiling a project with the 10.6SDK , but running on 10.7, all my faders were reversed when using the mouse wheel.
Will try to stick with the 10.7SDK, but maybe someone else will have the surprise…

Salvator


#11

True, but there’s really nothing I can do about that. People should really be using the latest SDK anyway, it doesn’t make much sense to use an older one.


#12

You can do it like this in your mouseWheelEvent

bool negative = false; #if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 if([NSEvent instancesRespondToSelector:@selector(isDirectionInvertedFromDevice:)]) negative = [theEvent isDirectionInvertedFromDevice]; #endif
This could help perhaps?


#13

We’re still using 10.5/10.5 (Base/Deployment SDK) as plugins made with 10.6/10.5 crash on 10.5 systems. This might have changed in the meantime and we didn’t switch to 10.7 / XCode 4 for development yet but my previous impression of this Base/Deployment stuff is that it’s a great idea that unfortunately doesn’t work.

Chris


#14

[quote=“Best4gotten”]You can do it like this in your mouseWheelEvent

bool negative = false; #if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 if([NSEvent instancesRespondToSelector:@selector(isDirectionInvertedFromDevice:)]) negative = [theEvent isDirectionInvertedFromDevice]; #endif
This could help perhaps?[/quote]

Thanks, I do already do it that way, which is fine for anyone using a newer SDK, but some people are still using pre-10.6 SDKs.