boolean readSelectionFromPasteboard(NSPasteboard pboard, NSString type) { boolean result = false; NSString newSelection = null; if (type.isEqualToString(OS.NSStringPboardType)) { NSString string = pboard.stringForType(OS.NSStringPboardType); if (string != null && string.length() > 0) { newSelection = string; } } if (newSelection != null) { Accessible acc = getAccessible(); acc.internal_accessibilitySetValue_forAttribute(newSelection, OS.NSAccessibilitySelectedTextAttribute, ACC.CHILDID_SELF); result = true; } return result; }
boolean writeSelectionToPasteboard(NSPasteboard pboard, NSString type) { boolean result = false; if (type.isEqualToString(OS.NSStringPboardType)) { Accessible acc = getAccessible(); id selection = acc.internal_accessibilityAttributeValue(OS.NSAccessibilitySelectedTextAttribute, ACC.CHILDID_SELF); if (selection != null) { NSString selectionString = new NSString(selection); if (selectionString.length() > 0) result = pboard.setString(selectionString, OS.NSStringPboardType); } } return result; }
long /*int*/ validRequestorForSendType(long /*int*/ id, long /*int*/ sel, long /*int*/ sendType, long /*int*/ returnType) { if (id == view.id) { Accessible acc = getAccessible(); if (acc != null) { // This returns null if there are no additional overrides. Since this is only checked to see if there is // a StyledText or other control that supports reading and writing of the selection there's no need to bother // with checking the default values. They will be picked up in the default implementation. NSArray attributes = acc.internal_accessibilityAttributeNames(ACC.CHILDID_SELF); if (attributes != null) { boolean canReturn = attributes.containsObject(OS.NSAccessibilitySelectedTextAttribute); boolean canSend = acc.internal_accessibilityIsAttributeSettable(OS.NSAccessibilitySelectedTextAttribute, ACC.CHILDID_SELF); boolean canHandlePBoardType = supportedPboardTypes.containsObject(new id(sendType)) && supportedPboardTypes.containsObject(new id(returnType)); if (canReturn && canSend && canHandlePBoardType) { id selection = acc.internal_accessibilityAttributeValue(OS.NSAccessibilitySelectedTextAttribute, ACC.CHILDID_SELF); if (selection != null) { NSString selectionString = new NSString(selection); if (selectionString.length() > 0) return view.id; } } } } } return super.validRequestorForSendType(id, sel, sendType, returnType); }
}); Accessible accessible = canvas.getAccessible(); accessible.addAccessibleListener(new AccessibleAdapter() { @Override
Accessible accessible = customButton.getAccessible(); accessible.addAccessibleListener(new AccessibleAdapter() { @Override
overrideCanvas.getAccessible().addAccessibleListener(overrideAccessibleAdapter);