/**
* TSubMenu is a special case menu item that wraps another TMenu.
*/
-public class TSubMenu extends TMenuItem {
+public final class TSubMenu extends TMenuItem {
/**
* The menu window. Note package private access.
public void draw() {
super.draw();
- CellAttributes background = getTheme().getColor("tmenu");
CellAttributes menuColor;
- CellAttributes menuMnemonicColor;
- if (getAbsoluteActive()) {
+ if (isAbsoluteActive()) {
menuColor = getTheme().getColor("tmenu.highlighted");
- menuMnemonicColor = getTheme().getColor("tmenu.mnemonic.highlighted");
} else {
- if (getEnabled()) {
+ if (isEnabled()) {
menuColor = getTheme().getColor("tmenu");
- menuMnemonicColor = getTheme().getColor("tmenu.mnemonic");
} else {
menuColor = getTheme().getColor("tmenu.disabled");
- menuMnemonicColor = getTheme().getColor("tmenu.disabled");
}
}
@Override
public void onKeypress(final TKeypressEvent keypress) {
- if (menu.getActive()) {
+ // Open me if they hit my mnemonic.
+ if (!keypress.getKey().isFnKey()
+ && !keypress.getKey().isAlt()
+ && !keypress.getKey().isCtrl()
+ && (getMnemonic() != null)
+ && (Character.toLowerCase(getMnemonic().getShortcut())
+ == Character.toLowerCase(keypress.getKey().getChar()))
+ ) {
+ dispatch();
+ return;
+ }
+
+ if (menu.isActive()) {
menu.onKeypress(keypress);
return;
}
*/
@Override
public void dispatch() {
- assert (getEnabled());
- if (getAbsoluteActive()) {
- if (!menu.getActive()) {
+ assert (isEnabled());
+ if (isAbsoluteActive()) {
+ if (!menu.isActive()) {
getApplication().addSubMenu(menu);
menu.setActive(true);
}
*/
@Override
public TWidget getActiveChild() {
- if (menu.getActive()) {
+ if (menu.isActive()) {
return menu;
}
// Menu not active, return me
* @param key global keyboard accelerator
* @return the new menu item
*/
- public final TMenuItem addItem(final int id, final String label,
+ public TMenuItem addItem(final int id, final String label,
final TKeypress key) {
return menu.addItem(id, label, key);
* @param label menu item label
* @return the new menu item
*/
- public final TMenuItem addItem(final int id, final String label) {
+ public TMenuItem addItem(final int id, final String label) {
return menu.addItem(id, label);
}
* (inclusive).
* @return the new menu item
*/
- public final TMenuItem addDefaultItem(final int id) {
+ public TMenuItem addDefaultItem(final int id) {
return menu.addDefaultItem(id);
}
/**
* Convenience function to add a menu separator.
*/
- public final void addSeparator() {
+ public void addSeparator() {
menu.addSeparator();
}
* denoted by prefixing a letter with "&", e.g. "&File"
* @return the new sub-menu
*/
- public final TSubMenu addSubMenu(final String title) {
+ public TSubMenu addSubMenu(final String title) {
return menu.addSubMenu(title);
}