FROM : Timothy Paustian
DATE : Wed Nov 20 19:45:01 2002
I have a view that has several graphics in it. From this I want to be
able to allows users to drag out a jpeg and/or gif to other parts of
the application or even to other applications. I have this working
for tiffs and here is the code I use. (Note I know the command key
thing is a bit non-standard, but it works for what I am trying to do.
How can I modify this code to get me a jpeg or gif?
- (void)mouseDown:(NSEvent *)theEvent
{
NSSize dragOffset = NSMakeSize(0.0, 0.0);
NSPasteboard *pboard;
unsigned int modifiers = [theEvent modifierFlags];
if(modifiers & NSCommandKeyMask)
{
NSRect bounds = [self bounds];
NSImage *image = [[[NSImage alloc] initWithSize: bounds.size]
autorelease];
NSImage *dragImage = [[[NSImage alloc] initWithSize:
bounds.size] autorelease];
NSPoint dragPoint = NSMakePoint(0.0, 0.0);
pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
[pboard declareTypes:[NSArray
arrayWithObject:NSTIFFPboardType] owner:self];
[image lockFocus];
[self drawRect:bounds];
[image unlockFocus];
[pboard setData: [image TIFFRepresentationUsingCompression:
NSTIFFCompressionLZW factor: 15.0] forType:
NSTIFFPboardType];
[dragImage setBackgroundColor:[NSColor clearColor]];
[dragImage lockFocus];
[image dissolveToPoint: dragPoint fraction: 0.5];
[dragImage unlockFocus];
[self dragImage:dragImage
at:bounds.origin
offset: dragOffset
event:theEvent
pasteboard:pboard
source:self slideBack:YES];
}
else
{
[super mouseDown:theEvent];
}
return;
}
--
Cheers,
Tim
Timothy Paustian
UW-Madison, Bacteriology
DATE : Wed Nov 20 19:45:01 2002
I have a view that has several graphics in it. From this I want to be
able to allows users to drag out a jpeg and/or gif to other parts of
the application or even to other applications. I have this working
for tiffs and here is the code I use. (Note I know the command key
thing is a bit non-standard, but it works for what I am trying to do.
How can I modify this code to get me a jpeg or gif?
- (void)mouseDown:(NSEvent *)theEvent
{
NSSize dragOffset = NSMakeSize(0.0, 0.0);
NSPasteboard *pboard;
unsigned int modifiers = [theEvent modifierFlags];
if(modifiers & NSCommandKeyMask)
{
NSRect bounds = [self bounds];
NSImage *image = [[[NSImage alloc] initWithSize: bounds.size]
autorelease];
NSImage *dragImage = [[[NSImage alloc] initWithSize:
bounds.size] autorelease];
NSPoint dragPoint = NSMakePoint(0.0, 0.0);
pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
[pboard declareTypes:[NSArray
arrayWithObject:NSTIFFPboardType] owner:self];
[image lockFocus];
[self drawRect:bounds];
[image unlockFocus];
[pboard setData: [image TIFFRepresentationUsingCompression:
NSTIFFCompressionLZW factor: 15.0] forType:
NSTIFFPboardType];
[dragImage setBackgroundColor:[NSColor clearColor]];
[dragImage lockFocus];
[image dissolveToPoint: dragPoint fraction: 0.5];
[dragImage unlockFocus];
[self dragImage:dragImage
at:bounds.origin
offset: dragOffset
event:theEvent
pasteboard:pboard
source:self slideBack:YES];
}
else
{
[super mouseDown:theEvent];
}
return;
}
--
Cheers,
Tim
Timothy Paustian
UW-Madison, Bacteriology
| Related mails | Author | Date |
|---|---|---|
| Timothy Paustian | Nov 20, 19:45 | |
| Fabio Lossotti | Nov 21, 07:15 | |
| Andrew Zamler-Carh… | Nov 21, 10:22 |






Cocoa mail archive

