X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTWidget.java;h=e8cd1a0e7e68a79f83d6de41f685a39aad379b81;hb=e23ea53820244957b17a7000c6d3e1ff586f1ef0;hp=4a4ba2ce18190f361ba1830d4983b66a62565ec3;hpb=4c46ea176c25101865057accbfe01da1d9b6b8ab;p=fanfix.git diff --git a/src/jexer/TWidget.java b/src/jexer/TWidget.java index 4a4ba2c..e8cd1a0 100644 --- a/src/jexer/TWidget.java +++ b/src/jexer/TWidget.java @@ -1098,12 +1098,19 @@ public abstract class TWidget implements Comparable { return; } - if (child != activeChild) { - if (activeChild != null) { - activeChild.active = false; + if (children.size() == 1) { + if (children.get(0).enabled == true) { + child.active = true; + activeChild = child; + } + } else { + if (child != activeChild) { + if (activeChild != null) { + activeChild.active = false; + } + child.active = true; + activeChild = child; } - child.active = true; - activeChild = child; } } @@ -1114,6 +1121,14 @@ public abstract class TWidget implements Comparable { * isn't enabled, then the next enabled child will be activated. */ public final void activate(final int tabOrder) { + if (children.size() == 1) { + if (children.get(0).enabled == true) { + children.get(0).active = true; + activeChild = children.get(0); + } + return; + } + if (activeChild == null) { return; } @@ -1144,11 +1159,25 @@ public abstract class TWidget implements Comparable { */ public final void switchWidget(final boolean forward) { - // Only switch if there are multiple enabled widgets - if ((children.size() < 2) || (activeChild == null)) { + // No children: do nothing. + if (children.size() == 0) { + return; + } + + // If there is only one child, make it active if it is enabled. + if (children.size() == 1) { + if (children.get(0).enabled == true) { + activeChild = children.get(0); + activeChild.active = true; + } else { + children.get(0).active = false; + activeChild = null; + } return; } + // Two or more children: go forward or backward to the next enabled + // child. int tabOrder = activeChild.tabOrder; do { if (forward) {