1 Clazz.declarePackage ("java.awt.event");
2 Clazz.load (["java.awt.event.InputEvent"], "java.awt.event.MouseEvent", ["java.lang.IllegalArgumentException", "$.StringBuilder", "java.awt.Point", "$.Toolkit"], function () {
3 c$ = Clazz.decorateAsClass (function () {
10 this.popupTrigger = false;
11 Clazz.instantialize (this, arguments);
12 }, java.awt.event, "MouseEvent", java.awt.event.InputEvent);
13 Clazz.defineMethod (c$, "getLocationOnScreen",
15 return new java.awt.Point (this.xAbs, this.yAbs);
17 Clazz.defineMethod (c$, "getXOnScreen",
21 Clazz.defineMethod (c$, "getYOnScreen",
25 Clazz.makeConstructor (c$,
26 function (source, id, when, modifiers, x, y, clickCount, popupTrigger, button) {
27 this.construct (source, id, when, modifiers, x, y, 0, 0, clickCount, popupTrigger, button);
28 var eventLocationOnScreen = new java.awt.Point (0, 0);
30 eventLocationOnScreen = source.getLocationOnScreen ();
31 this.xAbs = eventLocationOnScreen.x + x;
32 this.yAbs = eventLocationOnScreen.y + y;
34 if (Clazz.exceptionOf (e, java.awt.IllegalComponentStateException)) {
41 }, "java.awt.Component,~N,~N,~N,~N,~N,~N,~B,~N");
42 Clazz.makeConstructor (c$,
43 function (source, id, when, modifiers, x, y, clickCount, popupTrigger) {
44 this.construct (source, id, when, modifiers, x, y, clickCount, popupTrigger, 0);
45 }, "java.awt.Component,~N,~N,~N,~N,~N,~N,~B");
46 Clazz.makeConstructor (c$,
47 function (source, id, when, modifiers, x, y, xAbs, yAbs, clickCount, popupTrigger, button) {
48 Clazz.superConstructor (this, java.awt.event.MouseEvent, [source, id, when, modifiers]);
53 this.clickCount = clickCount;
54 this.popupTrigger = popupTrigger;
55 if (button < 0 || button > 3) {
56 throw new IllegalArgumentException ("Invalid button value");
57 }this.button = button;
58 if ((this.getModifiers () != 0) && (this.getModifiersEx () == 0)) {
59 this.setNewModifiers ();
60 } else if ((this.getModifiers () == 0) && (this.getModifiersEx () != 0 || button != 0)) {
61 this.setOldModifiers ();
62 }}, "java.awt.Component,~N,~N,~N,~N,~N,~N,~N,~N,~B,~N");
63 Clazz.defineMethod (c$, "getX",
67 Clazz.defineMethod (c$, "getY",
71 Clazz.defineMethod (c$, "getPoint",
78 }return new java.awt.Point (x, y);
80 Clazz.defineMethod (c$, "translatePoint",
85 Clazz.defineMethod (c$, "getClickCount",
87 return this.clickCount;
89 Clazz.defineMethod (c$, "getButton",
93 Clazz.defineMethod (c$, "isPopupTrigger",
95 return this.popupTrigger;
97 c$.getMouseModifiersText = Clazz.defineMethod (c$, "getMouseModifiersText",
98 function (modifiers) {
99 var buf = new StringBuilder ();
100 if ((modifiers & 8) != 0) {
101 buf.append (java.awt.Toolkit.getProperty ("AWT.alt", "Alt"));
103 }if ((modifiers & 4) != 0) {
104 buf.append (java.awt.Toolkit.getProperty ("AWT.meta", "Meta"));
106 }if ((modifiers & 2) != 0) {
107 buf.append (java.awt.Toolkit.getProperty ("AWT.control", "Ctrl"));
109 }if ((modifiers & 1) != 0) {
110 buf.append (java.awt.Toolkit.getProperty ("AWT.shift", "Shift"));
112 }if ((modifiers & 32) != 0) {
113 buf.append (java.awt.Toolkit.getProperty ("AWT.altGraph", "Alt Graph"));
115 }if ((modifiers & 16) != 0) {
116 buf.append (java.awt.Toolkit.getProperty ("AWT.button1", "Button1"));
118 }if ((modifiers & 8) != 0) {
119 buf.append (java.awt.Toolkit.getProperty ("AWT.button2", "Button2"));
121 }if ((modifiers & 4) != 0) {
122 buf.append (java.awt.Toolkit.getProperty ("AWT.button3", "Button3"));
124 }if (buf.length () > 0) {
125 buf.setLength (buf.length () - 1);
126 }return buf.toString ();
128 Clazz.overrideMethod (c$, "paramString",
130 var str = new StringBuilder (80);
131 str.append (java.awt.event.MouseEvent.getIdString (this.id));
132 str.append (",(" + this.x).append ("," + this.y).append ("," + this.when).append (")");
133 str.append (",absolute(").append ("" + this.xAbs).append (",").append ("" + this.yAbs).append (")");
134 str.append (",button=").append ("" + this.getButton ());
135 if (this.getModifiers () != 0) {
136 str.append (",modifiers=").append (java.awt.event.MouseEvent.getMouseModifiersText (this.modifiers));
137 }if (this.getModifiersEx () != 0) {
138 str.append (",extModifiers=").append (java.awt.event.InputEvent.getModifiersExText (this.modifiers));
139 }str.append (",clickCount=").append ("" + this.clickCount);
140 return str.toString ();
142 c$.getIdString = Clazz.defineMethod (c$, "getIdString",
146 return "MOUSE_PRESSED";
148 return "MOUSE_RELEASED";
150 return "MOUSE_CLICKED";
152 return "MOUSE_ENTERED";
154 return "MOUSE_EXITED";
156 return "MOUSE_MOVED";
158 return "MOUSE_DRAGGED";
160 return "MOUSE_WHEEL";
162 return "unknown type";
165 Clazz.defineMethod (c$, "setNewModifiers",
167 if ((this.modifiers & 16) != 0) {
168 this.modifiers |= 1024;
169 }if ((this.modifiers & 8) != 0) {
170 this.modifiers |= 2048;
171 }if ((this.modifiers & 4) != 0) {
172 this.modifiers |= 4096;
173 }if (this.id == 501 || this.id == 502 || this.id == 500) {
174 if ((this.modifiers & 16) != 0) {
176 this.modifiers &= -13;
177 if (this.id != 501) {
178 this.modifiers &= -1025;
179 }} else if ((this.modifiers & 8) != 0) {
181 this.modifiers &= -21;
182 if (this.id != 501) {
183 this.modifiers &= -2049;
184 }} else if ((this.modifiers & 4) != 0) {
186 this.modifiers &= -25;
187 if (this.id != 501) {
188 this.modifiers &= -4097;
189 }}}if ((this.modifiers & 8) != 0) {
190 this.modifiers |= 512;
191 }if ((this.modifiers & 4) != 0) {
192 this.modifiers |= 256;
193 }if ((this.modifiers & 1) != 0) {
194 this.modifiers |= 64;
195 }if ((this.modifiers & 2) != 0) {
196 this.modifiers |= 128;
197 }if ((this.modifiers & 32) != 0) {
198 this.modifiers |= 8192;
200 Clazz.defineMethod (c$, "setOldModifiers",
202 if (this.id == 501 || this.id == 502 || this.id == 500) {
203 switch (this.button) {
205 this.modifiers |= 16;
215 if ((this.modifiers & 1024) != 0) {
216 this.modifiers |= 16;
217 }if ((this.modifiers & 2048) != 0) {
219 }if ((this.modifiers & 4096) != 0) {
221 }}if ((this.modifiers & 512) != 0) {
223 }if ((this.modifiers & 256) != 0) {
225 }if ((this.modifiers & 64) != 0) {
227 }if ((this.modifiers & 128) != 0) {
229 }if ((this.modifiers & 8192) != 0) {
230 this.modifiers |= 32;
232 Clazz.defineStatics (c$,
235 "MOUSE_CLICKED", 500,
236 "MOUSE_PRESSED", 501,
237 "MOUSE_RELEASED", 502,
239 "MOUSE_ENTERED", 504,
241 "MOUSE_DRAGGED", 506,