[OS X Emacs] Aquamacs for Lion - update

David Reitter david.reitter at gmail.com
Thu Oct 6 22:49:37 EDT 2011


On Oct 6, 2011, at 6:59 PM, <siemsen at ucar.edu> <siemsen at ucar.edu> wrote:

> I'd like to see support for dragging strings out of Aquamacs, as I can do with other Cocoa apps.  I mean highlight a string in Aquamacs, then click-and-hold the mouse button and drag the highlighted string to another app.

Yes, someone could give it a shot.  I looked it up, and it's actually not difficult to do.

Catch the event of somebody dragging the mouse from within an active region (as opposed to outside, in which case we don't do anything special).  Could be done by changing `mouse-drag-region'.

Put the text into a new pasteboard (or save the old text). 

Implement C-level function (e.g., in nsfns.m or nsterm.m)  to connect to the NSWindow API.  Take a snapshot of the text (preferably with the region disabled, or simply the text drawn into an off-screen buffer, so we don't have to deal with weird colors, non-rectangular selections, and so on).

Then, call dragImage:at:offset:event:pasteboard:source:slideBack: for the EmacsView or EmacsWindow, and I think that's it.


Documentation reference:

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/DragandDrop/Concepts/dragsource.html#//apple_ref/doc/uid/20000976-CJBFBADF
http://www.cocoabuilder.com/archive/cocoa/30404-translucent-image-for-dragging.html
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSBitmapImageRep_Class/Reference/Reference.html

Any takers?  Send me your code by Monday!


--
http://aquamacs.org -- Aquamacs: Emacs on Mac OS X
http://aquamacs.org/donate -- Could we help you? Return the favor and support the Aquamacs Project!


More information about the MacOSX-Emacs mailing list