Module: josm/ui/menu

Provides a collection of namespaces, classes and functions to work with JOSMs menu system.
Source:

Example

import {JSAction} from 'josm/ui/menu'

Classes

MenuBar

Members


<static, constant> JSAction

JSAction is an action for which a menu item or a toolbar item can be added to JOSMs menu or JOSMs toolbar respectively. This is just a shortcut for the Java class JSAction. The constructor accepts an object with {@link module:josm/ui/menu~JSActionOptions named parameters}.
Properties:
Name Type Description
JSAction JSAction
Source:
Example
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))

Type Definitions


JSActionCallback()

Callback type for JSAction
Source:

JSActionOptions

The named options for building a JSAction.
Properties:
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.
Source: