X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fmenu%2FTMenu.java;h=58228f9900d1c311bf947be32410da6f0ea50427;hb=9f613a0c54cb97e9305fd87ce8eb2f76ac82804e;hp=8a8ec6be752d1443e60969baa5505671a567279f;hpb=e9bb3c1e57e52ea19a153059a3f42656ea6ed51c;p=fanfix.git diff --git a/src/jexer/menu/TMenu.java b/src/jexer/menu/TMenu.java index 8a8ec6b..58228f9 100644 --- a/src/jexer/menu/TMenu.java +++ b/src/jexer/menu/TMenu.java @@ -37,6 +37,7 @@ import jexer.TWindow; import jexer.bits.CellAttributes; import jexer.bits.GraphicsChars; import jexer.bits.MnemonicString; +import jexer.bits.StringUtils; import jexer.event.TKeypressEvent; import jexer.event.TMouseEvent; import static jexer.TKeypress.*; @@ -128,8 +129,9 @@ public class TMenu extends TWindow { public static final int MID_TABLE_INSERT_BELOW = 107; public static final int MID_TABLE_COLUMN_NARROW = 110; public static final int MID_TABLE_COLUMN_WIDEN = 111; - public static final int MID_TABLE_FILE_SAVE_CSV = 115; - public static final int MID_TABLE_FILE_SAVE_TEXT = 116; + public static final int MID_TABLE_FILE_OPEN_CSV = 115; + public static final int MID_TABLE_FILE_SAVE_CSV = 116; + public static final int MID_TABLE_FILE_SAVE_TEXT = 117; // ------------------------------------------------------------------------ // Variables -------------------------------------------------------------- @@ -176,7 +178,7 @@ public class TMenu extends TWindow { assert (mnemonic.getShortcutIdx() >= 0); // Recompute width and height to reflect an empty menu - setWidth(getTitle().length() + 4); + setWidth(StringUtils.width(getTitle()) + 4); setHeight(2); setActive(false); @@ -270,15 +272,21 @@ public class TMenu extends TWindow { /* System.err.printf("keypress: %s active child: %s\n", keypress, getActiveChild()); - */ + */ if (getActiveChild() != this) { - if ((getActiveChild() instanceof TSubMenu) - || (getActiveChild() instanceof TMenu) - ) { + if (getActiveChild() instanceof TMenu) { getActiveChild().onKeypress(keypress); return; } + + if (getActiveChild() instanceof TSubMenu) { + TSubMenu subMenu = (TSubMenu) getActiveChild(); + if (subMenu.menu.isActive()) { + subMenu.onKeypress(keypress); + return; + } + } } if (keypress.equals(kbEsc)) { @@ -310,12 +318,18 @@ public class TMenu extends TWindow { if (!keypress.getKey().isFnKey() && !keypress.getKey().isAlt() && !keypress.getKey().isCtrl()) { + + // System.err.println("Checking children for mnemonic..."); + for (TWidget widget: getChildren()) { TMenuItem item = (TMenuItem) widget; - if ((item.getMnemonic() != null) + if ((item.isEnabled() == true) + && (item.getMnemonic() != null) && (Character.toLowerCase(item.getMnemonic().getShortcut()) == Character.toLowerCase(keypress.getKey().getChar())) ) { + // System.err.println("activate: " + item); + // Send an enter keystroke to it activate(item); item.handleEvent(new TKeypressEvent(kbEnter)); @@ -659,6 +673,12 @@ public class TMenu extends TWindow { label = i18n.getString("menuHelpAbout"); break; + case MID_TABLE_RENAME_COLUMN: + label = i18n.getString("menuTableRenameColumn"); + break; + case MID_TABLE_RENAME_ROW: + label = i18n.getString("menuTableRenameRow"); + break; case MID_TABLE_VIEW_ROW_LABELS: label = i18n.getString("menuTableViewRowLabels"); checkable = true; @@ -742,6 +762,9 @@ public class TMenu extends TWindow { label = i18n.getString("menuTableColumnWiden"); key = kbShiftRight; break; + case MID_TABLE_FILE_OPEN_CSV: + label = i18n.getString("menuTableFileOpenCsv"); + break; case MID_TABLE_FILE_SAVE_CSV: label = i18n.getString("menuTableFileSaveCsv"); break;