else if (button == 2) new SimpleMessage("Press2", T, Box.whoIs(root, mousex, mousey));
else if (button == 3) {
final Box who = Box.whoIs(root, mousex, mousey);
- Scheduler.add(new Scheduler.Task() { public void perform() {
+ Scheduler.add(new Scheduler.Task() { public void perform() throws JSExn {
Platform.clipboardReadEnabled = true;
- root.putAndTriggerTraps("Press3", T);
- Platform.clipboardReadEnabled = false;
+ try {
+ root.putAndTriggerTraps("Press3", T);
+ } finally {
+ Platform.clipboardReadEnabled = false;
+ }
}});
}
}
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);
+ try {
+ b.putAndTriggerTraps("KeyPressed", key);
+ } catch (JSExn e) {
+ Log.log(Surface.class, "Exception thrown from KeyPressed handler");
+ Log.logJS(e);
+ }
}
Platform.clipboardReadEnabled = false;
}
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);
+ try {
+ b.putAndTriggerTraps("KeyReleased", key);
+ } catch (JSExn e) {
+ Log.log(Surface.class, "Exception thrown from KeyReleased handler");
+ Log.logJS(e);
+ }
}
}});
}
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.putAndTriggerTraps("Move", T);
+ try {
+ root.putAndTriggerTraps("Move", T);
+ } catch (JSExn e) {
+ Log.log(Surface.class, "Exception thrown from Move message handler");
+ Log.logJS(e);
+ }
root.Move(oldmousex, oldmousey, mousex, mousey);
if (!cursor.equals(oldcursor)) syncCursor();
}
}
// FEATURE: can we avoid creating objects here?
+ /** subclasses should invoke this method when the user resizes the window */
protected final void SizeChange(final int width, final int height) {
Scheduler.addAtFront(new Scheduler.Task() { public void perform() {
// dirty the place where the scar used to be
root.dirty(0, root.maxheight - Main.scarImage.height, Main.scarImage.width, Main.scarImage.height);
root.setMaxWidth(JS.N(width));
root.setMaxHeight(JS.N(height));
- root.set(root.REFLOW);
}});
abort = true;
}
// FEATURE: can we avoid creating objects here?
protected final void PosChange(final int x, final int y) {
- Scheduler.add(new Scheduler.Task() { public void perform() {
+ Scheduler.add(new Scheduler.Task() { public void perform() throws JSExn {
root.x = x;
root.y = y;
root.putAndTriggerTraps("PosChange", T);
Scheduler.add(this);
}
- public void perform() { boxContainingMouse.putAndTriggerTraps(name, value); }
+ public void perform() throws JSExn { boxContainingMouse.putAndTriggerTraps(name, value); }
public String toString() { return "SimpleMessage [name=" + name + ", value=" + value + "]"; }
}