Widget's right click menu support add custom menuitem. you can create "menu" node in "widget.json" file to create custom menuitem. Custom MenuItem can bind measure to send command to measure or run javascript code.
Measures are also can auto create custom menuitem by default. if you do not need custom menuitem by measure ,just add this code in measure section "autoCreateCustomMenu" : false
You can run javascript code when the menuitem was clicked by set the measure to blank and set the js code into the onClick property. It can execute multiple js statements at the same time.