I am trying to write an app. that will allow the user to drag from an NSButton
to another. When dropped I would like the Title to be dropped onto the button.
I cannot find a way to make NSButton
draggable. Is it possible?
I am trying to write an app. that will allow the user to drag from an NSButton
to another. When dropped I would like the Title to be dropped onto the button.
I cannot find a way to make NSButton
draggable. Is it possible?
First a warning: this sounds like it would be confusing to a user. Buttons are intended to emulate buttons in the real world. You push them rather than drag them around.
Having said that, it's certainly possible to do in a subclass of NSButton.
Drag source
[NSPasteboard pasteboardWithName:NSDragPboard]
) and copy your button title into it. For the image you can draw your button into an NSImage and use that as the drag image, or you might use an icon or even just the title.Drag destination
There's lots of info out there on implementing drag & drop. Read Apple's docs: Drag & Drop Programming Topics and Pasteboard Programming Guide