(Quick Reference)

5.10 Platform Specific - Reference Documentation

Authors: Andres Almiray

Version: 1.2.0

5.10 Platform Specific

The following sections outline specific tweaks and options available for a particular platform.

5.10.1 Tweaks for a Particular Platform

Griffon will automatically apply tweaks to the application depending on the current platform. However you have the option to specify a different set of tweaks. For example, the following configuration in Config.groovy specifies a different handler for macosx:

platform {
    handler = [
        macosx: 'com.acme.MyMacOSXPlatformHandler'
    ]
}

Now you only need to create such handler, like this:

package com.acme

import griffon.core.GriffonApplication import griffon.util.PlatformHandler

class MyMacOSXPlatformHandler implements PlatformHandler { void handle(GriffonApplication app) { System.setProperty('apple.laf.useScreenMenuBar', 'true') … } }

The following platform keys are recognized by the application in order to locate a particular handler: linux, macosx, solaris and windows.

5.10.2 MacOSX

Applications that run in Apple's MacOSX must adhere to an strict set of rules. We recommend you to have a look at Apple's (Human Interface Guidelines).

Griffon makes it easier to integrate with MacOSX by automatically registering a couple of System properties that make the applicaiton behave like a native one

  • apple.laf.useScreenMenuBar - if set to true will force the application's menu bar to appear at the top. Griffon sets its value to true.
  • com.apple.mrj.application.apple.menu.about.name - sets the name that will appear next to the About menu option.

Java applications running on MacOSX also have the option to register handlers for About, Preferences and Quit menu options. The default handlers will trigger an specific application event each. These events can be disabled with a command flag set in griffon-app/conf/Config.groovy. The following table outlines the events, flags and the default behavior when the flags are enabled

EventFired whenFlagDefault behavior
OSXAboutuser activates About menuosx.noaboutDefault about dialog is displayed
OSXPrefsuser activates Preferences menuosx.noprefsNo Preferences menu is available
OSXQuituser activates Quit menuosx.noquitApplication shutdowns immediately