# Class: oPieMenu

## $. oPieMenu

A type of menu with nested levels that appear around the mouse

#### new $.oPieMenu(name, widgets, minAngle, maxAngle, radius, position, show, sliceColor)

openHarmony/openHarmony_dialog.js, line 416
  The $.oPieMenu constructor.

  Name | Type | Default | Description
  --- | --- | --- | ---
  `name` | string |  | The name for this pie Menu.
  `widgets` | Array.<QWidget> |  | optional The widgets to display in the menu.
  `minAngle` | float |  | optional The low limit of the range of angles used by the menu, in multiples of PI (0 : left, 0.5 : top, 1 : right, -0.5 : bottom)
  `maxAngle` | float |  | optional The high limit of the range of angles used by the menu, in multiples of PI (0 : left, 0.5 : top, 1 : right, -0.5 : bottom)
  `radius` | float |  | optional The radius of the menu.
  `position` | $.oPoint |  | optional The central position of the menu.
  `show` | bool | false | optional Whether to immediately show the dialog.
  `sliceColor` | QColor |  | optional The color of the slices.

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `name` | string | The name for this pie Menu.
  `widgets` | Array.<QWidget> | The widgets to display in the menu.
  `minAngle` | float | The low limit of the range of angles used by the menu, in multiples of PI (0 : left, 0.5 : top, 1 : right, -0.5 : bottom)
  `maxAngle` | float | The high limit of the range of angles used by the menu, in multiples of PI (0 : left, 0.5 : top, 1 : right, -0.5 : bottom)
  `radius` | float | The radius of the menu.
  `position` | $.oPoint | The central position of the menu or button position for imbricated menus.
  `menuWidget` | QWidget | The central position of the menu or button position for imbricated menus.

  ##### Example

      // This example function creates a menu full of generated push buttons with callbacks, but any type of widget can be added.
      // Normally it doesn't make sense to create buttons this way, and they will be created one by one to cater to specific needs,
      // such as launching Harmony actions, or scripts, etc. Assign this function to a shortcut by creating a Harmony Package for it.

      function openMenu(){

        // make a callback factory for our buttons and provide access to the openHarmony object
        var oh = $;
        function getCallback(message){
          var $ = oh;
          var message = message;
          return function(){
            $.alert(message);
          }
        }

        // we create a list of random widgets for our submenu
        var subwidgets = [];
        for (var i=0; i<5; i++){
          var button = new QPushButton;
          button.text = i;

          var callback = getCallback("submenu button "+i);
          button.clicked.connect(callback);

          subwidgets.push(button);
        }

        // we initialise our submenu
        var subMenu = new $.oPieSubMenu("more", subwidgets);

        // we create a list of random widgets for our main menu
        var widgets = [];
        for (var i=0; i<8; i++){
          var button = new QPushButton;
          button.text = i;

          var callback = getCallback("button "+i);
          button.clicked.connect(callback);

          widgets.push(button);
        }

        // we swap one of our widgets for the submenu
        widgets[3] = subMenu;

        // we initialise our main menu. The numerical values are for the minimum and maximum angle of the
        // circle in multiples of Pi. Going counter clockwise, 0 is right, 1 is left, 1.5 is the bottom from the left,
        // and -0.5 is the bottom from the right side. 0.5 is the top of the circle.
        var menu = new $.oPieMenu("menu", widgets, -0.2, 1.2);

        // we show it!
        menu.show();
      }

### Methods

#### show(parent)

openHarmony/openHarmony_dialog.js, line 519
  Build and show the pie menu.

  Name | Type | Description
  --- | --- | ---
  `parent` | $.oPieMenu | optional specify a parent oPieMenu for imbricated submenus