this.updateAction = updateAction;
- field = new TField(this, 0, 0, width - 3, false, "",
- updateAction, null);
+ field = addField(0, 0, width - 3, false, "", updateAction, null);
if (valuesIndex >= 0) {
field.setText(values.get(valuesIndex));
}
- list = new TList(this, values, 0, 1, width, valuesHeight,
+ list = addList(values, 0, 1, width, valuesHeight,
new TAction() {
public void DO() {
field.setText(list.getSelected());
// Constructors -----------------------------------------------------------
// ------------------------------------------------------------------------
+ /**
+ * Public constructor.
+ *
+ * @param parent parent widget
+ * @param x column relative to parent
+ * @param y row relative to parent
+ * @param width number of text cells for width of the image
+ * @param height number of text cells for height of the image
+ * @param image the image to display
+ * @param left left column of the image. 0 is the left-most column.
+ * @param top top row of the image. 0 is the top-most row.
+ */
+ public TImage(final TWidget parent, final int x, final int y,
+ final int width, final int height,
+ final BufferedImage image, final int left, final int top) {
+
+ this(parent, x, y, width, height, image, left, top, null);
+ }
+
/**
* Public constructor.
*
BufferedImage image = ImageIO.read(file);
- imageField = new TImage(this, 0, 0, getWidth() - 2, getHeight() - 2,
- image, 0, 0, null);
+ imageField = addImage(0, 0, getWidth() - 2, getHeight() - 2,
+ image, 0, 0);
setTitle(file.getName());
setupAfterImage();
import jexer.bits.GraphicsChars;
/**
- * TField implements an editable text field.
+ * TPasswordField implements an editable text field that displays
+ * stars/asterisks when it is not active.
*/
public class TPasswordField extends TField {
import static jexer.TKeypress.*;
/**
- * TSpinner implements a simple up/down spinner. Values can be numer
+ * TSpinner implements a simple up/down spinner.
*/
public class TSpinner extends TWidget {
super(parent, title, 0, 0, parent.getScreen().getWidth() / 2,
parent.getScreen().getHeight() / 2 - 2, RESIZABLE | CENTERED);
- tableField = new TTableWidget(this, 0, 0, getWidth() - 2, getHeight() - 2);
+ tableField = addTable(0, 0, getWidth() - 2, getHeight() - 2);
setupAfterTable();
}
*/
package jexer;
+import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
moveAction);
}
+ /**
+ * Convenience function to add an image to this container/window.
+ *
+ * @param x column relative to parent
+ * @param y row relative to parent
+ * @param width number of text cells for width of the image
+ * @param height number of text cells for height of the image
+ * @param image the image to display
+ * @param left left column of the image. 0 is the left-most column.
+ * @param top top row of the image. 0 is the top-most row.
+ */
+ public final TImage addImage(final int x, final int y,
+ final int width, final int height,
+ final BufferedImage image, final int left, final int top) {
+
+ return new TImage(this, x, y, width, height, image, left, top);
+ }
+
+ /**
+ * Convenience function to add an image to this container/window.
+ *
+ * @param x column relative to parent
+ * @param y row relative to parent
+ * @param width number of text cells for width of the image
+ * @param height number of text cells for height of the image
+ * @param image the image to display
+ * @param left left column of the image. 0 is the left-most column.
+ * @param top top row of the image. 0 is the top-most row.
+ * @param clickAction function to call when mouse is pressed
+ */
+ public final TImage addImage(final int x, final int y,
+ final int width, final int height,
+ final BufferedImage image, final int left, final int top,
+ final TAction clickAction) {
+
+ return new TImage(this, x, y, width, height, image, left, top,
+ clickAction);
+ }
+
+ /**
+ * Convenience function to add an editable 2D data table to this
+ * container/window.
+ *
+ * @param x column relative to parent
+ * @param y row relative to parent
+ * @param width width of widget
+ * @param height height of widget
+ */
+ public TTableWidget addTable(final int x, final int y, final int width,
+ final int height) {
+
+ return new TTableWidget(this, x, y, width, height);
+ }
+
}
final String text) {
super(parent, title, 0, 0, 44, 22, RESIZABLE);
- editField = new TEditorWidget(this, text, 0, 0, 42, 20);
+ editField = addEditor(text, 0, 0, 42, 20);
statusBar = newStatusBar(i18n.getString("statusBar"));
statusBar.addShortcutKeypress(kbF1, cmHelp,
/*
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)) {
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));