BUTTON: Fix bug that click event when the right mouse button
authorHyunJong Park <paulhj.park@samsung.com>
Tue, 26 Jul 2016 00:23:00 +0000 (09:23 +0900)
committerHyunJong Park <paulhj.park@samsung.com>
Tue, 26 Jul 2016 00:23:19 +0000 (09:23 +0900)
When the right mouse button, set foucs the button.

Change-Id: I46e127be9a40703e1e45001781ed42676afe97d1
Signed-off-by: HyunJong Park <paulhj.park@samsung.com>
bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TizenAbstractButtonRenderer.java
bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TizenButton.java
bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TizenPushButtonRenderer.java
bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TizenRadioButtonRenderer.java

index 9902842..1ab6f90 100644 (file)
@@ -32,11 +32,14 @@ public abstract class TizenAbstractButtonRenderer {
     protected Composite parentComposite = null;
 
     protected static final int MARGIN = 5;
+    protected static final int MOUSE_LEFT = 1;
+    protected static final int MOUSE_RIGHT = 3;
+
     protected boolean isFocus = false;
     protected boolean isSelection = false;
     protected boolean isEnable = true;
 
-    protected static boolean isFocusFromTabKey = false;
+    protected static boolean isFocusByKeyInput = false;
 
     protected boolean isDefaultButton = false;
     protected boolean isGrayed = false;
@@ -111,12 +114,12 @@ public abstract class TizenAbstractButtonRenderer {
         return false;
     }
 
-    protected void setFocusFromTabKey(boolean isFocusFromTabKey) {
-        this.isFocusFromTabKey = isFocusFromTabKey;
+    protected void setFocusByKeyInput(boolean isFocusFromTabKey) {
+        this.isFocusByKeyInput = isFocusFromTabKey;
     }
 
-    protected boolean isFocusFromTabKey() {
-        return isFocusFromTabKey;
+    protected boolean isFocusByKeyInput() {
+        return isFocusByKeyInput;
     }
 
     protected boolean isActiveDefaultButton() {
index 7f1921b..7c377b3 100644 (file)
@@ -153,7 +153,7 @@ public class TizenButton extends Canvas {
 
         this.addListener(SWT.FocusIn, new Listener() {
             public void handleEvent(Event e) {
-                TizenButton.this.buttonRenderer.setFocusFromTabKey(true);
+                TizenButton.this.buttonRenderer.setFocusByKeyInput(true);
                 TizenButton.this.buttonRenderer.setFocus();
             }
         });
@@ -175,6 +175,10 @@ public class TizenButton extends Canvas {
                 case SWT.CR:
                     fireEventWhenEnterKeyPressed();
                     break;
+                case SWT.ESC:
+//                    Display.getCurrent().g
+//                    Display.getCurrent().getActiveShell().dispose();
+                    break;
                 }
             }
         });
@@ -389,7 +393,7 @@ public class TizenButton extends Canvas {
             return false;
         }
         super.setFocus();
-        TizenButton.this.buttonRenderer.setFocusFromTabKey(false);
+        buttonRenderer.setFocusByKeyInput(false);
         buttonRenderer.setFocus();
         return true;
     }
index 16dba77..a0c65af 100644 (file)
@@ -188,7 +188,7 @@ public class TizenPushButtonRenderer extends TizenAbstractButtonRenderer {
             return true;
         }
 
-        if (null != button && isFocusFromTabKey()) {
+        if (null != button && isFocusByKeyInput()) {
             return false;
         }
         return true;
@@ -216,11 +216,19 @@ public class TizenPushButtonRenderer extends TizenAbstractButtonRenderer {
                     if (!isEnable) {
                         break;
                     }
-                    isButtonPressed = true;
+                    if (event.button == MOUSE_RIGHT) {
+                        parent.setFocus();
+                    } else {
+                        isButtonPressed = true;
+                    }
+                    setFocusByKeyInput(true);
                     parent.redraw();
-
                     break;
                 case SWT.MouseUp:
+                    if (event.button == MOUSE_RIGHT) {
+                        return;
+                    }
+
                     /*
                      * To check that click on the button of current window.
                      * Some widgets open a new window when the mouse down.
@@ -258,7 +266,7 @@ public class TizenPushButtonRenderer extends TizenAbstractButtonRenderer {
                 }
                 switch (event.character) {
                 case SWT.ESC:
-                    Display.getCurrent().getActiveShell().dispose();
+//                    Display.getCurrent().getActiveShell().dispose();
                     break;
                 case SWT.CR:
                     /*
@@ -356,7 +364,7 @@ public class TizenPushButtonRenderer extends TizenAbstractButtonRenderer {
     }
 
     private void drawBorder(GC gc, Rectangle rect, TizenButtonAttribute attr) {
-        if (isEnable && isFocus() && isFocusFromTabKey == true) {
+        if (isEnable && isFocus() && isFocusByKeyInput == true) {
             drawHighlightBorder(gc, rect, parent.getAttribute());
         } else if (isActiveDefaultButton() && parent.isEnabled()) {
             drawHighlightBorder(gc, rect, parent.getAttribute());
index fcd475e..fc536f6 100644 (file)
@@ -38,6 +38,10 @@ public class TizenRadioButtonRenderer extends TizenAbstractButtonRenderer {
 
     TizenRadioButtonRenderer(TizenButton parent, Composite parentComposite) {
         super(parent, parentComposite);
+        if (parentComposite instanceof Group) {
+            this.setEnabled(parentComposite.getEnabled());
+        }
+
     }
 
     protected boolean isState(int style, int cmpStyle) {
@@ -56,7 +60,16 @@ public class TizenRadioButtonRenderer extends TizenAbstractButtonRenderer {
                 case SWT.MouseExit:
                     drawMouseExit();
                     break;
+                case SWT.MouseDown:
+                    if (event.button == MOUSE_RIGHT) {
+                        parent.setFocus();
+                        return;
+                    }
+                    break;
                 case SWT.MouseUp:
+                    if (event.button == MOUSE_RIGHT) {
+                        return;
+                    }
                     radioButtonPressed();
                     break;
                 case SWT.Paint: