- protected final void DoubleClick(int button) {
- if (button == 1) new SimpleMessage("DoubleClick1", T, Box.whoIs(root, mousex, mousey));
- else if (button == 2) new SimpleMessage("DoubleClick2", T, Box.whoIs(root, mousex, mousey));
- else if (button == 3) new SimpleMessage("DoubleClick3", T, Box.whoIs(root, mousex, mousey));
- }
-
- /** Send a KeyPressed message; subclasses should not add the C- or A- prefixes or should they capitalize alphabet chars */
- 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;
- 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 implements Scheduler.Task {
- 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.putAndTriggerTraps("KeyPressed", key);
- }
- Platform.clipboardReadEnabled = false;
- }
- }
-
- /** sends a KeyReleased message; subclasses should not add the C- or A- prefixes or capitalize alpha chars */
- 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 Scheduler.Task() { 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.putAndTriggerTraps("KeyReleased", key);
- }
- }});
- }
-