Event to trigger writeSelectionToPasteboard
site_archiver@lists.apple.com Delivered-To: cocoa-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=g4+e8q1j+sHfMqtrxQEHhnTdJSWtgB0pe1iOSzJ42zY=; b=hBYdcN3Ac3uCb+CKnYjIEVYIbgADd5XotSyS77ZDmqr7khrHU2qWyywosLon80NL7T mhIivNO+DLf5WXPBP84ct4bsoIP12mOrftfIjq3XTrsxjW3hfNFt0hXI92Q87wGmRmWH WPB/hrJ+v2ERWnItpkFt2gdOuSfH83U7ubolw= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=jfGczd9qo2j0aZGY1IkRt4A4zHXJegO3U7U6ZQQJeRD5yyOjk8iRNnXcdPpioBSqnu E47rmZGzDAKkjIQIuRQoDycZKuCrVsE8PSz5+ECan8fp72CV3Zh/fsO7nOvBzB2ic4q4 3/nuKXyAaShGkc3iN77X+WtU64fMTnWtEguis= I'm writing an app that lets the user select text in one program and paste it into another by middle-clicking the mouse button. This roughly emulates the X11 selection buffer. The first version I wrote used event taps to detect when the user dragged a selection (doesn't work for a double-click select or shift-arrow select). It then compiled and ran an apple script to "get the contents of the selection" in the frontmost app. When the user middle-clicked, the app would retype (using CGEvents) everything it got from the apple script. This worked OK except: 1) Only a few apps support "get the contents of the selection" 2) It's slow to send events for every keystroke (and undo-buffers get confused) The next version called two services I made, "Copy Selection" and "Paste Selection". This works with all Cocoa apps (fixes #1), is fast (fixes #2), but I haven't found a way to programmatically invoke a service (in another app). The best I could come up with was setting command-key equivalents for the services and sending those command-keys through UI scripting. The nasty side effect of this is that every time you drag a selection, the app's app menu gets selected. This is unacceptable-I don't want my menu bar flashing each time I drag the mouse. I know that each Cocoa app implements writeSelectionToPasteboard(), and I'm guessing this is how services interact with running apps. Each service is a separate short-running process. Sothere must be some sort of IPC to get the selection from the running app into the service's pasteboard. If I can figure out what that IPC is, I can send a message to a running application, and this would avoid flashing the menu bar. Any ideas on getting another app to run its writeSelectionToPasteboard() method? Thanks, Peter _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/site_archiver%40lists.apple... This email sent to site_archiver@lists.apple.com
participants (1)
-
Peter Watkins