Although using commands and handlers provides a generic way for reusing content, it is possible to provide a shorter route to implementing menus with a Direct Menu Item. The difference between this and a Handled Menu Item is that Direct Menu Item contains a direct reference to the @Executable
class, instead of indirect through a handler.
To add a new direct menu item, open the
Application.e4xmi
file and navigate to the Application | Windows and Dialogs | Trimmed Window | Main Menu | Menu (File). Right-click on the menu and choose Add child | Direct Menu Item. In the dialog shown, fill in the following details, including the class URI link to theHelloHandler
, defined previously:ID:
com.packtpub.e4.application.directmenuitem.hello
Label:
Direct Hello
Class URI:
bundleclass://com.packtpub.e4.application/com.packtpub.e4.application.handlers.HelloHandler
Run the application, and navigate to the File | Direct Hello menu, which shows the...