Permalink
Browse files

restore clipboard behavior.

  • Loading branch information...
1 parent 83ef367 commit 1cec0c6e383224a510f8beec027cd49f501f03d8 @jessegrosjean jessegrosjean committed Nov 3, 2011
Showing with 9 additions and 4 deletions.
  1. +9 −4 QCUIElement.m
View
@@ -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;
}
@@ -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];
@@ -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;
}

0 comments on commit 1cec0c6

Please sign in to comment.