Revision: 2722 http://skim-app.svn.sourceforge.net/skim-app/?rev=2722&view=rev Author: hofman Date: 2007-08-27 01:49:55 -0700 (Mon, 27 Aug 2007)
Log Message: ----------- Fix actions and validation for imageView. Modified Paths: -------------- trunk/BDSKDragImageView.m Modified: trunk/BDSKDragImageView.m =================================================================== --- trunk/BDSKDragImageView.m 2007-08-26 20:43:17 UTC (rev 2721) +++ trunk/BDSKDragImageView.m 2007-08-27 08:49:55 UTC (rev 2722) @@ -87,17 +87,28 @@ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { SEL action = [menuItem action]; - if (action == @selector(copy:)) - return [self image] && [delegate respondsToSelector:@selector(dragImageView:writeDataToPasteboard:)]; - else if (action == @selector(delete:)) + if (action == @selector(cut:) || action == @selector(copy:) || action == @selector(delete:) || action == @selector(show:)) return [self image] != nil; - else if (action == @selector(show:)) - return [self image] != nil; + else if (action == @selector(paste:)) + return YES; else if ([[BDSKDragImageView superclass] instancesRespondToSelector:_cmd]) [super validateMenuItem:menuItem]; return YES; } +- (NSMenu *)menuForEvent:(NSEvent *)theEvent { + NSMenu *menu = [[[super menuForEvent:theEvent] copy] autorelease]; + int i = [menu numberOfItems]; + + while (i-- > 0) { + NSMenuItem *item = (NSMenuItem *)[menu itemAtIndex:i]; + if ([self validateMenuItem:item] == NO) + [menu removeItem:item]; + } + + return [menu numberOfItems] ? menu : nil; +} + - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender{ NSDragOperation dragOp = NSDragOperationNone; if ([delegate respondsToSelector:@selector(dragImageView:validateDrop:)]) @@ -124,19 +135,13 @@ return [delegate dragImageView:self acceptDrop:sender]; return NO; } -/* -- (void)keyDown:(NSEvent *)theEvent { - NSString *characters = [theEvent charactersIgnoringModifiers]; - unichar eventChar = [characters length] > 0 ? [characters characterAtIndex:0] : 0; - unsigned modifierFlags = [theEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask; + +- (void)mouseDown:(NSEvent *)theEvent { + if ([theEvent clickCount] == 2) { + [self show:self]; + return; + } - if ((eventChar == NSDeleteCharacter || eventChar == NSDeleteFunctionKey) && modifierFlags == 0 && [self image]) - [self delete:self]; - else - [super keyDown:theEvent]; -} -*/ -- (void)mouseDown:(NSEvent *)theEvent { BOOL keepOn = YES; BOOL isInside = YES; NSPoint mouseLoc; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit