Localize strings
[fanfix.git] / src / jexer / TButton.java
index 1c995c47a4375d69d4f735b43b49dec69b73aa67..3b60cad037bba20c10d2f4d6520738a774ca2159 100644 (file)
@@ -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;
         }