Class 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 the following optional named parameters.

name:string
The optional name of the action. Default: an auto generated named.
tooltip:string
The optional tooltip of the action. Default: empty string.
iconName:string
The optional name of an icon. Default: null.
toolbarId:string
The optional name of the tooblar, this action is going to be added to later. Note, that it isn't added automatically, when this action is created. Default: null.
onExecute:function
The (optional) function which is called when the action is executed. Default: null.
onInitEnabled:function
The (optional) function which is called when the enabled state of the function is evaluated the first time. Default: null.
onUpdateEnabled:function
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.
var JSAction = require("josm/ui/menu").JSAction;
var action = new JSAction({
	  name: "My Action",
   tooltip: "This is my action",
   onInitEnabled: function() {
      this.enabled = false;
   }
});

action.onExecute = function() {
   josm.alert("Action is executing ...");
};