|
Adding menu items to the contextual menus
Since Ellié Computing Merge 2.2, you can add items to the contextual menus with scripts. When displaying a contextual menu in the views, ECMerge calls the function "query_contextual_menu" on itself. By default, this function is undefined and therefore nothing happens. However if this function returns a menu item Array (as defined in the Application.popup_menu function), a "Macros" menu item is inserted at the top of the contextual menu, its sub-menu is the menu returned by the function. An exampleThis example adds a dummy menu item to the folders view contextual menu, which displays "hi hoo" when clicked. FolderDocument.View.prototype.query_contextual_menu =
function () { More insightECMAScript defines prototyping semanitcs, this is some kind run-time value oriented in-heritance. What it means is that specific View objects are derived from less specific View: FolderDocument.View (as well as ImageDocument.View or TextDocument.View) derives from Document.View. If you place your function on Document.View it will thus be seen in all the views, this is interesting for menu items with general interest. On the other hand, menu items of interest for a single type of view should go in the appropriate ???Document.View object. You can change the contextual menu for a single view also though it is harder to see interest in this. How to use both shared menu items and per-view type menu itemsHere is an example of how it can be done: FolderDocument.View.prototype.query_contextual_menu =
function () {
|
|