Skip to content

Commit

Permalink
Added docs on Action
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray committed May 18, 2012
1 parent b4cb319 commit 897469b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
53 changes: 52 additions & 1 deletion grails-doc/src/guide/controls/buttonsAndMenus/actions.gdoc
@@ -1 +1,52 @@
actions
GroovyFX provides an action abstraction inspired by [javax.swing.Action|http://docs.oracle.com/javase/6/docs/api/javax/swing/Action.html].
All Action properties are fully observable

h4. JavaFX Components Supporting @Action@

All buttons and menuItems support @Action@ but only if their respective factories are used. In other words, if you manually
create an instance of such controls then you must also bind Action properties manually.

The following table describes the properties used by JavaFX components that support Actions.

{table}
*Action Property* | *Component Property* | *Notes*
onAction | onAction | if component supports @onActionProperty()@
name | text | if component supports @textProperty()@
description | tooltip.text | if component supports @tooltipProperty()@
accelerator | accelerator | if component supports @acceleratorProperty()@
selected | selected | if component supports @selectedProperty()@
icon | graphic | if component supports @graphicProperty()@
enabled | disabled | negated value is mapped to component property
{table}

Any of the Action's properties may be skipped when using factory nodes, this avoids setting a text value on a toolbar button for example.
In order to skip a property simply use the @skip@ prefix. The following example shows the usage of Actions in both menuItems and toolbar
buttons; the menuItems will display both icons and text wehereas the toolbar buttons will only display the icons

{code}
actions {
fxaction(id: 'copyAction',
icon: 'icons/copy.png',
onAction: { /* copy content */ }
fxaction(id: 'cutyAction',
icon: 'icons/cut.png',
onAction: { /* cut content */ }
fxaction(id: 'pasteAction',
icon: 'icons/paste.png',
onAction: { /* paste content */ }
}

meuBar {
menu(text: "Edit") {
menuItem(cutAction)
menuItem(copyAction)
menuItem(pasteAction)
}
}

toolBar {
button(cutAction, skipName: true)
button(copyAction, skipName: true)
button(pasteAction, skipName: true)
}
{code}
2 changes: 1 addition & 1 deletion grails-doc/src/guide/gettingStarted/helloGroovyFX.gdoc
@@ -1,7 +1,7 @@
Once you have everything set up, try the following Groovy script to test that your setup is functioning as it should.

{code}
@Grab('org.codehaus.groovyfx:groovyfx:0.1')
@Grab('org.codehaus.groovyfx:groovyfx:0.2')

import static groovyx.javafx.GroovyFX.start

Expand Down

0 comments on commit 897469b

Please sign in to comment.