.. meta:: :description: Extensions Generic Menu Items Generic Menu Items ================== This section explains how to create and edit generic menu items. Usage ----- A generic menu item is a simple way to access common tasks from a menu, either from the top level or contextual. Menu items can also be defined as element of a plugin. .. _filesLocationGenericMenuItemExtension: File location ------------- To be recognized by the application, generic menu items should be located in one of these folders: - %LocalAppData%/ORS/Dragonfly(*version*)/pythonUserExtensions/GenericMenuItems (available for the current user) - %ProgramData%/ORS/Dragonfly(*version*)/pythonAllUsersExtensions/GenericMenuItems (available for all users) - %ProgramData%/ORS/Dragonfly(*version*)/python/OrsPythonPlugins/OrsGenericMenuItems/menuItems (distributed with the application) File creation ------------- To create a generic menu item, start the application, start the :mod:`OrsPythonPlugins.OrsGenericMenuItemGenerator.OrsGenericMenuItemGenerator` (found in *Developer/Generic Menu Item Generator*), fill in the required fields and press the button *Create menu item*. File edition ------------ Open the file in a text editor. Fill in the required methods. For more information about menu items, see :func:`ORSServiceClass.decorators.infrastructure.menuItem`. Demos ----- **Top level generic menu item** Source code example: #. Download the :download:`file `; #. Put that file into a :ref:`generic menu item extension folder `; #. Start the application; #. Open the top level menu *Demos* to see the menu item named *Demo: top level generic menu item*; #. By clicking on the menu item, a web browser will be opened on the Dragonfly developer site. **Contextual generic menu item** Source code example: #. Download the :download:`file `; #. Put that file into a :ref:`generic menu item extension folder `; #. Start the application; #. Import a dataset; #. Create a ROI having the same shape as the dataset; #. When selecting exactly 1 dataset and 1 ROI and doing a right-click on it, the contextual menu will contain the menu item named *Demo: overwrite channel with ROI*. If these objects have the same shape (size, spacing, direction), this menu item will be enabled. When clicking on that menu item, every painted pixel of the ROI will put a value of 0 in the dataset. .. seealso:: - :ref:`Class ChooseObjectAndNewName `