X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fmenu%2FTMenu.java;h=bfda60247a2f81ffe20afcd8599a94a06181cfe7;hb=a69ed767c9c07cf35cf1c5f7821fc009cfe79cd2;hp=3120635996e503fd43feb4bc24d3c031c43911bf;hpb=d625990deaa2c24624adc9fbd3fcab58891f5aef;p=nikiroo-utils.git diff --git a/src/jexer/menu/TMenu.java b/src/jexer/menu/TMenu.java index 3120635..bfda602 100644 --- a/src/jexer/menu/TMenu.java +++ b/src/jexer/menu/TMenu.java @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (C) 2017 Kevin Lamonte + * Copyright (C) 2019 Kevin Lamonte * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -161,6 +161,7 @@ public class TMenu extends TWindow { @Override public void onMouseDown(final TMouseEvent mouse) { this.mouse = mouse; + super.onMouseDown(mouse); // Pass to children for (TWidget widget: getChildren()) { @@ -341,7 +342,7 @@ public class TMenu extends TWindow { hLineXY(1 + 1, getHeight() - 1, getWidth() - 4, cHSide, background); // Draw a shadow - getScreen().drawBoxShadow(0, 0, getWidth(), getHeight()); + drawBoxShadow(0, 0, getWidth(), getHeight()); } // ------------------------------------------------------------------------ @@ -387,6 +388,21 @@ public class TMenu extends TWindow { return addItemInternal(id, label, null); } + /** + * Convenience function to add a menu item. + * + * @param id menu item ID. Must be greater than 1024. + * @param label menu item label + * @param enabled default state for enabled + * @return the new menu item + */ + public TMenuItem addItem(final int id, final String label, + final boolean enabled) { + + assert (id >= 1024); + return addItemInternal(id, label, null, enabled); + } + /** * Convenience function to add a custom menu item. *