X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTButton.java;h=255dd990738d369490a288d993dd24dd24890c49;hb=eb29bbb5ec70c43895dd0f053630c7e3cd402cba;hp=fc93c782b5fda5c66ff01a9297fc23ee53588837;hpb=a325f111c91ec64c0bb0319dedd18d36f4b720c9;p=nikiroo-utils.git diff --git a/src/jexer/TButton.java b/src/jexer/TButton.java index fc93c78..255dd99 100644 --- a/src/jexer/TButton.java +++ b/src/jexer/TButton.java @@ -73,27 +73,14 @@ public final class TButton extends TWidget { */ private TAction action; - /** - * The time at which dispatch() was called. - */ - private long dispatchTime; - - /** - * How long to animate dispatch of the event in millis. - */ - private static final long DISPATCH_TIME = 75; - /** * 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) { - long now = System.currentTimeMillis(); - if (now - dispatchTime > DISPATCH_TIME) { - action.DO(); - dispatchTime = now; - } + action.DO(); + inButtonPress = false; } } @@ -167,12 +154,6 @@ public final class TButton extends TWidget { shadowColor.setForeColor(Color.BLACK); shadowColor.setBold(false); - long now = System.currentTimeMillis(); - boolean inDispatch = false; - if (now - dispatchTime < DISPATCH_TIME) { - inDispatch = true; - } - if (!isEnabled()) { buttonColor = getTheme().getColor("tbutton.disabled"); menuMnemonicColor = getTheme().getColor("tbutton.disabled"); @@ -184,7 +165,7 @@ public final class TButton extends TWidget { menuMnemonicColor = getTheme().getColor("tbutton.mnemonic"); } - if (inButtonPress || inDispatch) { + if (inButtonPress) { getScreen().putCharXY(1, 0, ' ', buttonColor); getScreen().putStringXY(2, 0, mnemonic.getRawLabel(), buttonColor); getScreen().putCharXY(getWidth() - 1, 0, ' ', buttonColor); @@ -199,7 +180,7 @@ public final class TButton extends TWidget { GraphicsChars.CP437[0xDF], shadowColor); } if (mnemonic.getShortcutIdx() >= 0) { - if (inButtonPress || inDispatch) { + if (inButtonPress) { getScreen().putCharXY(2 + mnemonic.getShortcutIdx(), 0, mnemonic.getShortcut(), menuMnemonicColor); } else { @@ -235,7 +216,6 @@ public final class TButton extends TWidget { this.mouse = mouse; if (inButtonPress && mouse.isMouse1()) { - inButtonPress = false; // Dispatch the event dispatch(); }