X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTButton.java;h=3b60cad037bba20c10d2f4d6520738a774ca2159;hb=339652cc241d738d461670c3309eaf6fc85c992a;hp=748fe247c035b5dccf22acc913271fb0dbc30b10;hpb=e16dda65585466c8987bd1efd718431450a96605;p=fanfix.git diff --git a/src/jexer/TButton.java b/src/jexer/TButton.java index 748fe24..3b60cad 100644 --- a/src/jexer/TButton.java +++ b/src/jexer/TButton.java @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (C) 2016 Kevin Lamonte + * Copyright (C) 2017 Kevin Lamonte * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -73,6 +73,11 @@ public final class TButton extends TWidget { */ private TAction action; + /** + * 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. @@ -80,6 +85,7 @@ public final class TButton extends TWidget { public void dispatch() { if (action != null) { action.DO(); + inButtonPress = false; } } @@ -215,11 +221,8 @@ public final class TButton extends TWidget { this.mouse = mouse; if (inButtonPress && mouse.isMouse1()) { - inButtonPress = false; // Dispatch the event - if (action != null) { - action.DO(); - } + dispatch(); } } @@ -249,9 +252,7 @@ public final class TButton extends TWidget { || keypress.equals(kbSpace) ) { // Dispatch - if (action != null) { - action.DO(); - } + dispatch(); return; }