patch for bug 201898 - Too Easy to accidently drag Toolbar Bookmark folders. sr=pinkerton

git-svn-id: svn://10.0.0.236/trunk@165347 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
joshmoz%gmail.com
2004-11-14 09:34:24 +00:00
parent 205820eb93
commit 4ff1453aa4
2 changed files with 9 additions and 0 deletions

View File

@@ -45,6 +45,7 @@
@interface BookmarkButton : NSButton
{
BookmarkItem* mItem;
BOOL lastEventWasMenu;
}
-(id)initWithFrame:(NSRect)frame item:(BookmarkItem*)item;

View File

@@ -75,6 +75,7 @@
[self setImagePosition: NSImageLeft];
[self setRefusesFirstResponder: YES];
[self setFont: [NSFont labelFontOfSize: 11.0]];
lastEventWasMenu = NO;
}
return self;
}
@@ -172,6 +173,7 @@
-(NSMenu*)menuForEvent:(NSEvent*)aEvent
{
lastEventWasMenu = YES;
return [[BookmarkManager sharedBookmarkManager] contextMenuForItem:[self BookmarkItem] fromView:nil target:self];
}
@@ -207,6 +209,7 @@
NSPopUpButtonCell *popupCell = [[NSPopUpButtonCell alloc] initTextCell:@"" pullsDown:YES];
[popupCell setMenu: popupMenu];
[popupCell trackMouse:event inRect:[self bounds] ofView:self untilMouseUp:YES];
lastEventWasMenu = YES;
[popupCell release];
[bmMenu release];
[popupMenu release];
@@ -214,6 +217,7 @@
-(void)mouseDown:(NSEvent*)aEvent
{
lastEventWasMenu = NO;
[super mouseDown:aEvent];
if ([[self cell] lastClickHoldTimedOut])
[self showFolderPopup:aEvent];
@@ -229,6 +233,10 @@
- (void) mouseDragged: (NSEvent*) aEvent
{
// hack to prevent a drag while viewing a popup or context menu from moving the folder unexpectedly
// (unless the drag happens on the folder itself)
if (lastEventWasMenu && ([self hitTest:[[self superview] convertPoint:[aEvent locationInWindow] fromView:nil]] == nil))
return;
BookmarkItem *item = [self BookmarkItem];
BOOL isSingleBookmark = [item isKindOfClass:[Bookmark class]];
NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard];