X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fmenu%2FTSubMenu.java;h=c37bf3a1fcca4975185d083740189ad2708b9d9d;hb=8e688b9211599d240be67e5cf62dfe48520378f2;hp=24cc67d6739290c7803f42f356a906fa8d6914f4;hpb=b1b355b8d2d30a15dc2fbe364ad81cb895973d95;p=nikiroo-utils.git diff --git a/src/jexer/menu/TSubMenu.java b/src/jexer/menu/TSubMenu.java index 24cc67d..c37bf3a 100644 --- a/src/jexer/menu/TSubMenu.java +++ b/src/jexer/menu/TSubMenu.java @@ -30,6 +30,7 @@ */ package jexer.menu; +import jexer.TKeypress; import jexer.TWidget; import jexer.bits.CellAttributes; import jexer.bits.GraphicsChars; @@ -173,4 +174,59 @@ public class TSubMenu extends TMenuItem { return this; } + /** + * Convenience function to add a custom menu item. + * + * @param id menu item ID. Must be greater than 1024. + * @param label menu item label + * @param key global keyboard accelerator + * @return the new menu item + */ + public final TMenuItem addItem(final int id, final String label, + final TKeypress key) { + + return menu.addItem(id, label, key); + } + + /** + * Convenience function to add a menu item. + * + * @param id menu item ID. Must be greater than 1024. + * @param label menu item label + * @return the new menu item + */ + public final TMenuItem addItem(final int id, final String label) { + return menu.addItem(id, label); + } + + /** + * Convenience function to add one of the default menu items. + * + * @param id menu item ID. Must be between 0 (inclusive) and 1023 + * (inclusive). + * @return the new menu item + */ + public final TMenuItem addDefaultItem(final int id) { + return menu.addDefaultItem(id); + } + + /** + * Convenience function to add a menu separator. + */ + public final void addSeparator() { + menu.addSeparator(); + } + + /** + * Convenience function to add a sub-menu. + * + * @param title menu title. Title must contain a keyboard shortcut, + * denoted by prefixing a letter with "&", e.g. "&File" + * @return the new sub-menu + */ + public final TSubMenu addSubMenu(final String title) { + return menu.addSubMenu(title); + } + + }