From: Niki Roo Date: Thu, 2 Jan 2020 17:19:24 +0000 (+0100) Subject: Merge branch 'upstream-sep2019-sfix' into subtree X-Git-Url: http://git.nikiroo.be/?a=commitdiff_plain;h=cd7e80930437e18ac719f8e2c5d93c2ca0d23cd8;hp=-c;p=fanfix.git Merge branch 'upstream-sep2019-sfix' into subtree --- cd7e80930437e18ac719f8e2c5d93c2ca0d23cd8 diff --combined TButton.java index d86fa44,d1d7b39..d1d7b39 --- a/TButton.java +++ b/TButton.java @@@ -129,6 -129,20 +129,20 @@@ public class TButton extends TWidget this(parent, text, x, y); this.action = action; } + + /** + * The action to call when the button is pressed. + **/ + public TAction getAction() { + return action; + } + + /** + * The action to call when the button is pressed. + **/ + public void setAction(TAction action) { + this.action = action; + } // ------------------------------------------------------------------------ // Event handlers --------------------------------------------------------- diff --combined TWidget.java index 32ed806,e11a947..d60efd8 --- a/TWidget.java +++ b/TWidget.java @@@ -36,7 -36,6 +36,7 @@@ import java.util.ArrayList import jexer.backend.Screen; import jexer.bits.Cell; import jexer.bits.CellAttributes; +import jexer.bits.Clipboard; import jexer.bits.ColorTheme; import jexer.event.TCommandEvent; import jexer.event.TInputEvent; @@@ -185,7 -184,14 +185,7 @@@ public abstract class TWidget implement * @param enabled if true assume enabled */ protected TWidget(final TWidget parent, final boolean enabled) { - this.enabled = enabled; - this.parent = parent; - children = new ArrayList(); - - if (parent != null) { - this.window = parent.window; - parent.addChild(this); - } + this(parent, enabled, 0, 0, 0, 0); } /** @@@ -592,8 -598,9 +592,8 @@@ * @param command command event */ public void onCommand(final TCommandEvent command) { - // Default: do nothing, pass to children instead - for (TWidget widget: children) { - widget.onCommand(command); + if (activeChild != null) { + activeChild.onCommand(command); } } @@@ -1126,18 -1133,6 +1126,18 @@@ return null; } + /** + * Get the Clipboard. + * + * @return the Clipboard, or null if not assigned + */ + public Clipboard getClipboard() { + if (window != null) { + return window.getApplication().getClipboard(); + } + return null; + } + /** * Comparison operator. For various subclasses it sorts on: *