2

I'm building my first application, in which I have a custom NSView which is used for dragging and dropping files. I've got the registration of the dragging operation down, but still need to design the drag and drop area, so the users actually know that they can drop files on there.

I'd like the area to look something like this:
How do I get my drag and drop area to look like this?

I've tried some different things out in the drawRect function of my custom NSView class, but so far I haven't been able to even draw a dashed border.

Is it possible to draw something like this inside a NSView, and if so: how do I do it? Or should I just create a image of how I'd like my drag and drop area to look, and insert this into the view?
Thanks in advance.

anders
  • 457
  • 2
  • 19
  • Use picture. If you want a fast solution use PaintCode (even with demo you should be achieve your desired results) – Marek H Oct 04 '15 at 17:05
  • Yup. A picture was the way I ended up doing it. Thanks for your comment though. – anders Oct 04 '15 at 17:23

1 Answers1

1

If anyone else ever has this issue, the way I solved this was simply inserting an image into the NSView like this:

- (void)drawRect:(NSRect)dirtyRect {
    NSImage *image = [NSImage imageNamed:@"Dropzone"];
    [image drawInRect:dirtyRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1];
}

Seems by far to be the easiest way. Especially if you, or someone you know, knows how to do stuff in Photoshop or whatever.

This solution will also scale your image to fit the size of the view it is inserted into.

anders
  • 457
  • 2
  • 19