import {JSAction} from 'josm/ui/menu'
Name | Type | Description |
---|---|---|
JSAction |
JSAction |
import {JSAction} from 'josm/ui/menu' import * as util from 'josm/util' import josm from 'josm' const JMenuItem = Java.type('javax.swing.JMenuItem') // create the menu action const helloWorldAction = new JSAction({ name: "My Action", iconName: 'myicon', toolbarId: 'myToolbarId', tooltip: "This is my action", onInitEnabled: function() { util.println('onInitEnabled: entering ...') }, onUpdateEnabled: function() { util.println('onUpdateEnabled: entering ...') }, onExecute: function() { util.println('Hello World!') } }) // register a new menu item in the file menu const fileMenu = josm.menu.get('file') fileMenu.addSeparator() fileMenu.add(new JMenuItem(helloWorldAction))
Name | Type | Argument | Default | Description |
---|---|---|---|---|
name |
string |
<optional> |
The optional name of the action. Default: an auto generated name | |
tooltip |
string |
<optional> |
The optional tooltip of the action. Default: empty string | |
iconName |
string |
<optional> |
The optional name of an icon. Default: null | |
toolbarId |
string |
<optional> |
The optional name of the tooblar to which this action is added. Note that it isn't added automatically, when this action is created. Default: null. | |
onExecute |
module:josm/ui/menu~JSActionCallback |
<optional> |
null | The optional function which is called when the action is executed. Default: null. |
onInitEnabled |
module:josm/ui/menu~JSActionCallback |
<optional> |
null | The optional function which is called when the enabled state of the function is evaluated the first time. Default: null. |
onUpdateEnabled |
module:josm/ui/menu~JSActionCallback |
<optional> |
null | The (optional) function which is called when the enabled state of the function is reevaluated, in particular, when layer change events or selection change events occur. Default: null. |