int get_offsetAtPoint(int x, int y, int coordType, int /*long*/ pOffset) { AccessibleTextEvent event = new AccessibleTextEvent(this); event.x = x; event.y = y; event.offset = -1; for (int i = 0; i < accessibleTextExtendedListenersSize(); i++) { AccessibleTextExtendedListener listener = accessibleTextExtendedListeners.get(i); listener.getOffsetAtPoint(event); } if (DEBUG) print(this + ".IAccessibleText::get_offsetAtPoint(" + x + ", " + y + ") returning " + event.offset + hresult(event.offset == -1 ? COM.S_FALSE : COM.S_OK)); /* * Note that the current IA2 spec says to return 0 when there's nothing to return, * but since 0 is a valid return value, the spec is going to be updated to return -1. */ COM.MoveMemory(pOffset, new int [] { event.offset }, 4); if (event.offset == -1) return COM.S_FALSE; return COM.S_OK; }
id getRangeForPositionParameterizedAttribute(id parameter, int childID) { id returnValue = null; NSValue parameterObject = new NSValue(parameter.id); NSPoint point = parameterObject.pointValue(); NSRange range = new NSRange(); if (accessibleTextExtendedListenersSize() > 0) { NSArray screens = NSScreen.screens(); NSScreen screen = new NSScreen(screens.objectAtIndex(0)); NSRect frame = screen.frame(); point.y = frame.height - point.y; AccessibleTextEvent event = new AccessibleTextEvent(this); event.childID = childID; event.x = (int)point.x; event.y = (int)point.y; for (int i = 0; i < accessibleTextExtendedListenersSize(); i++) { AccessibleTextExtendedListener listener = (AccessibleTextExtendedListener) accessibleTextExtendedListeners.elementAt(i); listener.getOffsetAtPoint(event); } range.location = event.offset; range.length = 1; } else { //FIXME??? //how to implement with old listener } returnValue = NSValue.valueWithRange(range); return returnValue; }