1 34 35 36 package swingwt.awt.event; 37 38 import swingwt.awt.*; 39 40 public class MouseEvent extends InputEvent implements java.io.Serializable { 41 42 public static final int NOBUTTON = 0; 43 public static final int BUTTON1 = 1; 44 public static final int BUTTON2 = 2; 45 public static final int BUTTON3 = 3; 46 public static final int BUTTON1_MASK = BUTTON1; 47 public static final int BUTTON2_MASK = BUTTON2; 48 public static final int BUTTON3_MASK = BUTTON3; 49 50 public static final int MOUSE_FIRST = 500; 51 public static final int MOUSE_LAST = 507; 52 public static final int MOUSE_CLICKED = MOUSE_FIRST; 53 public static final int MOUSE_PRESSED = 1 + MOUSE_FIRST; 54 public static final int MOUSE_RELEASED = 2 + MOUSE_FIRST; 55 public static final int MOUSE_MOVED = 3 + MOUSE_FIRST; 56 public static final int MOUSE_ENTERED = 4 + MOUSE_FIRST; 57 public static final int MOUSE_EXITED = 5 + MOUSE_FIRST; 58 public static final int MOUSE_DRAGGED = 6 + MOUSE_FIRST; 59 public static final int MOUSE_WHEEL = 7 + MOUSE_FIRST; 60 61 public int clickCount = 1; 62 public int eventID = 0; 63 private int button = 0; 64 private int x = 0; 65 private int y = 0; 66 private boolean popupTrigger = false; 67 68 public static final int CLICKED = 0; 69 public static final int ENTERED = 1; 70 public static final int EXITED = 2; 71 public static final int PRESSED = 3; 72 public static final int RELEASED = 4; 73 74 public MouseEvent( Component source, int id, long when, int modifiers, 75 int x, int y, int clickCount, boolean popupTrigger ) { 76 this(source, id, when, modifiers, x, y, clickCount, popupTrigger, NOBUTTON); 77 } 78 79 public MouseEvent( Component source, int id, long when, int modifiers, int x, int y, 80 int clickCount, boolean popupTrigger, int button) { 81 super(source, id, when, modifiers); 82 83 this.x = x; 84 this.y = y; 85 this.clickCount = clickCount; 86 this.popupTrigger = popupTrigger; 87 this.button = button; 88 } 89 90 public MouseEvent(Component source) { 91 super(source); 92 } 93 94 99 public boolean isPopupTrigger() { 100 return button == 3; 101 } 102 103 public int getModifiers() { 104 return 0; 106 } 107 108 109 public int getClickCount() { 110 return clickCount; 111 } 112 113 117 public int getButton() { 118 return button; 119 } 120 121 125 public void setButton(int button) { 126 this.button = button; 127 } 128 129 133 public int getX() { 134 return x; 135 } 136 137 141 public void setX(int x) { 142 this.x = x; 143 } 144 145 149 public int getY() { 150 return y; 151 } 152 153 157 public void setY(int y) { 158 this.y = y; 159 } 160 161 public Point getPoint() { 162 return new Point(x, y); 163 } 164 165 public int translateSWTButton(int swtButton) { 166 int ret = NOBUTTON; 167 switch (swtButton) { 168 case (org.eclipse.swt.SWT.NONE): ret = NOBUTTON; break; 169 case (org.eclipse.swt.SWT.BUTTON1): ret = BUTTON1; break; 170 case (org.eclipse.swt.SWT.BUTTON2): ret = BUTTON2; break; 171 case (org.eclipse.swt.SWT.BUTTON3): ret = BUTTON3; break; 172 } 173 return ret; 174 } 175 } 176 | Popular Tags |