Document
|
xxxx
|
This facility provides a single pull-down menu on Tinguin. Other
blocks can register individual menu items by using the services
provided by this facility. It supports nested menu. To add an item,
you have to first get a handle to the top-level menu using the
getTopMenu
method in class
ApplicationsMenu
.
Once you have a handle to this object, you can add a simple menu item
using
registerApp()
or a submenu using
addSubMenu()
.
It is intended that other blocks will
use this method during their initialisation (invoked from
Library initialisation
service . At the end of library initialisation, the menu will be
closed. Attempts to register menu items after this will
fail.
If a block wants to register an application to be launchable from this
menu, the application must be implemented in the form of a class that
can be publicly instantiated and implements the MenuLaunchable
interface.
Here an example usage:
ApplicationsMenu.register(new AppMenuTest("topitem 1"), "TopItem 1");
// Get the top level menu and make a submenu
ApplicationsMenu top = ApplicationsMenu.getTopMenu();
ApplicationsMenu subMenu1 = top.addSubMenu("SubMenu 1");
subMenu1.registerApp (new AppMenuTest("subItem 1.1"), "SubItem 1.1");
subMenu1.registerApp (new AppMenuTest("subItem 1.2"), "SubItem 1.2");
// Make another submenu
ApplicationsMenu subMenu2 = subMenu1.addSubMenu("SubMenu 1.1");
subMenu2.registerApp (new AppMenuTest("subItem 2.1"), "SubItem 2.1");
subMenu2.registerApp (new AppMenuTest("subItem 2.2"), "SubItem 2.2");
In this case, the class AppMenuTest
implements the
MenuLaunchable
interface.
See the test program
AppMenuTest
for the current version.