* @return absolute screen column number for the cursor's X position
*/
public final int getCursorAbsoluteX() {
- assert (cursorVisible);
return getAbsoluteX() + cursorX;
}
* @return absolute screen row number for the cursor's Y position
*/
public final int getCursorAbsoluteY() {
- assert (cursorVisible);
return getAbsoluteY() + cursorY;
}
}
}
+ /**
+ * Method that subclasses can override to handle mouse button
+ * double-clicks.
+ *
+ * @param mouse mouse button event
+ */
+ public void onMouseDoubleClick(final TMouseEvent mouse) {
+ // Default: do nothing, pass to children instead
+ for (int i = children.size() - 1 ; i >= 0 ; i--) {
+ TWidget widget = children.get(i);
+ if (widget.mouseWouldHit(mouse)) {
+ // Dispatch to this child, also activate it
+ activate(widget);
+
+ // Set x and y relative to the child's coordinates
+ mouse.setX(mouse.getAbsoluteX() - widget.getAbsoluteX());
+ mouse.setY(mouse.getAbsoluteY() - widget.getAbsoluteY());
+ widget.handleEvent(mouse);
+ return;
+ }
+ }
+ }
+
/**
* Method that subclasses can override to handle window/screen resize
* events.
onMouseMotion(mouse);
break;
+ case MOUSE_DOUBLE_CLICK:
+ onMouseDoubleClick(mouse);
+ break;
+
default:
throw new IllegalArgumentException("Invalid mouse event type: "
+ mouse.getType());