- protected final void DoubleClick(int button) {
- if (button == 1) new SimpleMessage("DoubleClick1", Boolean.TRUE, Box.whoIs(root, mousex, mousey));
- else if (button == 2) new SimpleMessage("DoubleClick2", Boolean.TRUE, Box.whoIs(root, mousex, mousey));
- else if (button == 3) new SimpleMessage("DoubleClick3", Boolean.TRUE, Box.whoIs(root, mousex, mousey));
- }
-
- /** sends a KeyPressed message; subclasses should not add the C- or A- prefixes, nor should they capitalize alphabet characters */
- protected final void KeyPressed(String key) {
- if (key == null) return;
-
- if (key.toLowerCase().endsWith("shift")) shift = true;
- else if (shift) key = key.toUpperCase();
-
- if (key.toLowerCase().equals("alt")) alt = true;
- else if (alt) key = "A-" + key;
-
- if (key.toLowerCase().endsWith("control")) control = true;
- else if (control) key = "C-" + key;
-
- final String fkey = key;
- Scheduler.add(new KMessage(key));
- }
-
- // This is implemented as a private static class instead of an anonymous class to work around a GCJ bug
- private class KMessage extends Message {
- String key = null;
- public KMessage(String k) { key = k; }
- public void perform() {
- if (key.equals("C-v") || key.equals("A-v")) Platform.clipboardReadEnabled = true;
- outer: for(int i=0; i<keywatchers.size(); i++) {
- Box b = (Box)keywatchers.elementAt(i);
- for(Box cur = b; cur != null; cur = cur.parent)
- if (!cur.test(cur.VISIBLE)) continue outer;
- b.putAndTriggerJSTraps("KeyPressed", key);
- }
- Platform.clipboardReadEnabled = false;
- }
- }
-
- Vec keywatchers = new Vec();
-
- /** sends a KeyReleased message; subclasses should not add the C- or A- prefixes, nor should they capitalize alphabet characters */
- protected final void KeyReleased(final String key) {
- if (key == null) return;
- if (key.toLowerCase().equals("alt")) alt = false;
- else if (key.toLowerCase().equals("control")) control = false;
- else if (key.toLowerCase().equals("shift")) shift = false;
- Scheduler.add(new Message() { public void perform() {
- outer: for(int i=0; i<keywatchers.size(); i++) {
- Box b = (Box)keywatchers.elementAt(i);
- for(Box cur = b; cur != null; cur = cur.parent)
- if (!cur.test(cur.VISIBLE)) continue outer;
- b.putAndTriggerJSTraps("KeyReleased", key);
- }
- }});
+ /** we enqueue ourselves in the Scheduler when we have a Move message to deal with */
+ public void perform() {
+ if (mousex == newmousex && mousey == newmousey) return;
+ int oldmousex = mousex; mousex = newmousex;
+ int oldmousey = mousey; mousey = newmousey;
+ String oldcursor = cursor; cursor = "default";
+ // Root gets motion events outside itself (if trapped)
+ if (!root.inside(oldmousex, oldmousey) && !root.inside(mousex, mousey) && (button1 || button2 || button3))
+ root.putAndTriggerTrapsAndCatchExceptions("_Move", T);
+ if (!cursor.equals(oldcursor)) syncCursor();