X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTButton.java;h=064e927566effd281321502a7ad02031012fff84;hb=329fd62e4acdaa8e9f4cccd518d47c0b07e79f51;hp=ce04f5c79a51de37c935b71bd74e99043aa3dc49;hpb=7c870d89433346ccb5505f8f9ba62d3fc18fe996;p=fanfix.git diff --git a/src/jexer/TButton.java b/src/jexer/TButton.java index ce04f5c..064e927 100644 --- a/src/jexer/TButton.java +++ b/src/jexer/TButton.java @@ -1,4 +1,4 @@ -/** +/* * Jexer - Java Text User Interface * * License: LGPLv3 or later @@ -56,7 +56,7 @@ public final class TButton extends TWidget { * * @return mnemonic string */ - public final MnemonicString getMnemonic() { + public MnemonicString getMnemonic() { return mnemonic; } @@ -75,6 +75,16 @@ public final class TButton extends TWidget { */ private TAction action; + /** + * Act as though the button was pressed. This is useful for other UI + * elements to get the same action as if the user clicked the button. + */ + public void dispatch() { + if (action != null) { + action.DO(); + } + } + /** * Private constructor. * @@ -158,11 +168,11 @@ public final class TButton extends TWidget { if (inButtonPress) { getScreen().putCharXY(1, 0, ' ', buttonColor); - getScreen().putStrXY(2, 0, mnemonic.getRawLabel(), buttonColor); + getScreen().putStringXY(2, 0, mnemonic.getRawLabel(), buttonColor); getScreen().putCharXY(getWidth() - 1, 0, ' ', buttonColor); } else { getScreen().putCharXY(0, 0, ' ', buttonColor); - getScreen().putStrXY(1, 0, mnemonic.getRawLabel(), buttonColor); + getScreen().putStringXY(1, 0, mnemonic.getRawLabel(), buttonColor); getScreen().putCharXY(getWidth() - 2, 0, ' ', buttonColor); getScreen().putCharXY(getWidth() - 1, 0,