Java: Checking which scrolling direction is enabled in Mac OS Lion

With the introduce of Mac OS Lion Apple added the option to enable „natural scrolling“ which simply inverts the scrolling direction of input devices to get an iOS like scrolling behavior. However, some Apps may require to ‚invert the inverted scrolling‘, like Apps which use scrolling for zooming, which indeed should not be inverted. Unfortunately Apple dropped the development of Java and didn’t added a method or property to get the scrolling behaviour.

So today I tried to find a solution which helps to find out if natural scrolling is enabled or not in Java. I know that the preference would be saved in a .plist file so I checked with fseventer which one it was. After this the only thing I had to do was finding a library which allowed me to read .plist files and to check the scrolling property.

You will need this library to run the snippet.

try {
    File globalPref = new File(System.getProperty("user.home") + "/Library/Preferences/.GlobalPreferences.plist");
    NSDictionary dict = (NSDictionary)PropertyListParser.parse(globalPref);
    NSNumber pref = (NSNumber)dict.objectForKey("");
    if(pref.boolValue()) {
        //natural scrolling is enabled
} catch (Exception ex) {
    System.out.println("Faild to parse plist: " + ex.getMessage());

Hopefully this small snippet will be useful.

Category: Digitale Welt, Java, Macintosh, Programmieren | Tags: , , , , One comment »

One Response to “Java: Checking which scrolling direction is enabled in Mac OS Lion”

  1. Evonne

    I see a lot of interesting content on your page. You have to spend a lot
    of time writing, i know how to save you a lot of work, there
    is a tool that creates unique, SEO friendly
    posts in couple of seconds, just search in google – k2 unlimited content

Leave a Reply


Back to top