Skip to content

Commit

Permalink
restore clipboard behavior.
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegrosjean committed Nov 3, 2011
1 parent 83ef367 commit 1cec0c6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions QCUIElement.m
Expand Up @@ -344,10 +344,11 @@ - (NSString *)readString {
}
}

//NSPasteboard *pboard = [NSPasteboard generalPasteboard];
//NSString *savedContents = [pboard stringForType:NSPasteboardTypeString];
NSPasteboard *pboard = [NSPasteboard generalPasteboard];
NSString *savedContents = [pboard stringForType:NSPasteboardTypeString];
NSString *copiedContents = [self performCopee:YES];
//[pboard setString:savedContents forType:NSPasteboardTypeString]; // trying to restore original clip board contents... doesn't seem to work, not sure if good idaea anyway.
[pboard clearContents];
[pboard setString:savedContents forType:NSPasteboardTypeString]; // trying to restore original clip board contents... doesn't seem to work, not sure if good idaea anyway.
return copiedContents;
}

Expand All @@ -357,6 +358,7 @@ - (NSString *)readString {
- (BOOL)writeString:(NSString *)pasteString {
NSPasteboard *pboard = [NSPasteboard generalPasteboard];

NSString *savedContents = [pboard stringForType:NSPasteboardTypeString];
[pboard clearContents];
[pboard declareTypes:[NSArray arrayWithObject:NSPasteboardTypeString] owner:nil];
[pboard setString:pasteString forType:NSPasteboardTypeString];
Expand All @@ -369,10 +371,13 @@ - (BOOL)writeString:(NSString *)pasteString {

if ([pasteMenuItem enabled]) {
if (AXUIElementPerformAction(pasteMenuItem->uiElementRef, kAXPressAction) == kAXErrorSuccess) {
usleep(100000); // hack... might not work with long documents?
[pboard clearContents];
[pboard setString:savedContents forType:NSPasteboardTypeString];
return YES;
}
}
return NO;
}

Expand Down

0 comments on commit 1cec0c6

Please sign in to comment.