boolean readSelectionFromPasteboard(long /*int*/ id, long /*int*/ sel, long /*int*/ pasteboard) { boolean result = false; NSPasteboard pboard = new NSPasteboard(pasteboard); NSArray availableTypes = pboard.types(); NSString type; for (long /*int*/ i = 0; i < supportedPboardTypes.count(); i++) { if (result) break; type = new NSString(supportedPboardTypes.objectAtIndex(i)); if (availableTypes.containsObject(type)) { result = readSelectionFromPasteboard(pboard, type); } } 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); }
boolean writeSelectionToPasteboard(long /*int*/ id, long /*int*/ sel, long /*int*/ pasteboardObj, long /*int*/ typesObj) { boolean result = false; NSPasteboard pboard = new NSPasteboard(pasteboardObj); NSArray types = new NSArray(typesObj); NSMutableArray typesToDeclare = NSMutableArray.arrayWithCapacity(2); NSString type; for (long /*int*/ i = 0; i < supportedPboardTypes.count(); i++) { type = new NSString(supportedPboardTypes.objectAtIndex(i)); if (types.containsObject(type)) typesToDeclare.addObject(type); } if (typesToDeclare.count() > 0) { pboard.declareTypes(typesToDeclare, view); for (long /*int*/ i = 0; i < typesToDeclare.count(); i++) { type = new NSString(typesToDeclare.objectAtIndex(i)); if (writeSelectionToPasteboard(pboard, type)) result = true; } } return result; }
void update (boolean all) { // checkWidget(); NSArray isPainting = display.isPainting; if (isPainting.containsObject(view)) return; for (int i = 0, length = (int)/*64*/isPainting.count(); i < length; i++) { NSView view = new NSView(isPainting.objectAtIndex(i)); if (view.isDescendantOf(this.view)) return; } if (isResizing()) return; Shell shell = getShell(); NSWindow window = shell.deferFlushing && shell.scrolling ? view.window() : null; try { if (window != null) { window.retain(); window.disableFlushWindow(); } //TODO - not all view.displayIfNeeded (); } finally { if (window != null) { window.enableFlushWindow(); window.release(); } } }