Skip to content
Yoann Gini edited this page May 5, 2016 · 13 revisions

Introduction

This function allow us to create a new MenuList to add into the current one (can be nested).

With this function you will configure the name of the menu item to show in the parent one and the content to the MenuList associated to the menu item.

If sub menu items has a status, the parent menu item will summarize it by displaying the most critical state.

Main implementation

The main implementation of this function is made in the SubMenu plugin in the main project.

Settings

  • "title" a string to display in the parent menu item ;
  • "content" an array of dictionary describing included functions.

Those dictionaries must contains the following keys:

  • "functionIdentifier" a string to identify with function you want to load ; and may contains those:
  • "settings" a dictionary of options to pass to the function, read the function doc to know more about this.

Image

If submenu items has imagePath key, the string will be used as full path to be displayed on the left of the menu item.

If imagePath key is not set, Hello IT will look for imageBaseName key. This must be the base name for your icon in png file format located in /Library/Application Support/com.github.ygini.hello-it/CustomImageForItem.

For example, if imageBaseName is set to network, the app will look after the following resources:

  • /Library/Application Support/com.github.ygini.hello-it/CustomImageForItem/network.png
  • /Library/Application Support/com.github.ygini.hello-it/CustomImageForItem/network@2x.png
  • /Library/Application Support/com.github.ygini.hello-it/CustomImageForItem/network-dark.png
  • /Library/Application Support/com.github.ygini.hello-it/CustomImageForItem/network-dark@2x.png

Take care to image size, it will be displayed full size…

State

If submenu items display a status via a testState property (like built-in test functions) the menu will automatically resume it in its own state.

You can avoid this behavior by setting the skipForGlobalState key to true in sub item settings dictionary. For example, the Internet state wont be taken as a watched state:

...
        <dict>
            <key>functionIdentifier</key>
            <string>public.submenu</string>
            <key>settings</key>
            <dict>
                <key>content</key>
                <array>
                    <dict>
                        <key>functionIdentifier</key>
                        <string>public.test.http</string>
                        <key>settings</key>
                        <dict>
                            <key>URL</key>
                            <string>http://captive.apple.com</string>
                            <key>mode</key>
                            <string>md5</string>
                            <key>originalString</key>
                            <string>73a78ff5bd7e5e88aa445826d4d6eecb</string>
                            <key>repeat</key>
                            <integer>60</integer>
                            <key>imageBaseName</key>
                            <string>network</string>
                            <key>title</key>
                            <string>Internet</string>
                            <key>skipForGlobalState</key>
                            <true/>
                        </dict>
                    </dict>
                </array>
                <key>title</key>
                <string>Services state</string>
            </dict>
        </dict>
...

Notes

This function is used by the main program to create the main menu item. So be careful if you replace it by your own implementation.