Since OS X supports the "natural scrolling", my applications works wrong. The natural scrolling is made for scroll panes, which I really like. But, when I want to zoom in/out, it works wrong. So, what I want to do is check the scroll method for OS X.
If it is "natural" I'll take the opposite of the scroll values from MouseWheelEvent.getWheelRotation()
to make my zoom in/out behavior feel correct.
So, in short: How to know if OS X uses natural scrolling or not?
Found a solution.
First, you need a library to read .plist files. I used this one.
Than you can easily read in the GlobalPreferneces.plist (checked with fseventer which file is changed when changing the scroll option) to find out which kind of scrolling is enabled like this:
try {
File globalPref = new File(System.getProperty("user.home") + "/Library/Preferences/.GlobalPreferences.plist");
NSDictionary dict = (NSDictionary)PropertyListParser.parse(globalPref);
NSNumber pref = (NSNumber)dict.objectForKey("com.apple.swipescrolldirection");
if(pref.boolValue()) {
//natural scrolling is enabled
}
} catch (Exception ex) {
System.out.println("Faild to parse plist: " + ex.getMessage());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With