Add the ability to click-hold on bookmarks buttons to get a popup menu for folders and tab groups, and to be able to start a drag of a folder without holding any modifier keys. A quick click on a folder button still brings up the popup menu, and loads a tab group.

This commit is contained in:
sfraser%netscape.com 2003-03-11 07:59:27 +00:00
Родитель f4cd1afeec
Коммит 73a0a88b6d
1 изменённых файлов: 47 добавлений и 26 удалений

Просмотреть файл

@ -41,6 +41,15 @@
#import "BrowserWindowController.h"
#import "MainController.h"
@interface BookmarksButton(Private)
- (void)showFolderPopupAction:(id)aSender;
- (void)showFolderPopup:(NSEvent*)event;
@end
@implementation BookmarksButton
- (id)initWithFrame:(NSRect)frame
@ -70,6 +79,12 @@
return self;
}
- (void)dealloc
{
[super dealloc];
}
-(IBAction)openBookmark:(id)aSender
{
// Now load the URL in the window.
@ -180,14 +195,13 @@
return YES;
}
-(void)mouseDown:(NSEvent*)aEvent
- (void)showFolderPopupAction:(id)aSender
{
[self showFolderPopup:[NSApp currentEvent]];
}
- (void)showFolderPopup:(NSEvent*)event
{
// XXX we should decide whether to click or drag here based on timing, not
// whether the command key is down. We'll probably need to provide a custom
// Button Cell, and override trackMouse:inRect...
if (mBookmarkItem && mIsFolder && ([aEvent modifierFlags] & NSCommandKeyMask) == 0)
{
[self highlight:YES];
NSMenu* popupMenu = [[NSMenu alloc] init];
// dummy first item
[popupMenu addItemWithTitle:@"" action:NULL keyEquivalent:@""];
@ -198,16 +212,19 @@
NSPopUpButtonCell *popupCell = [[NSPopUpButtonCell alloc] initTextCell:@"" pullsDown:YES];
[popupCell setMenu: popupMenu];
[popupCell setFont:[NSFont labelFontOfSize: 11.0]];
[popupCell trackMouse:aEvent inRect:[self bounds] ofView:self untilMouseUp:YES];
[popupCell trackMouse:event inRect:[self bounds] ofView:self untilMouseUp:YES];
[popupCell release];
[bmMenu release];
[popupMenu release];
[self highlight:NO];
return;
}
}
-(void)mouseDown:(NSEvent*)aEvent
{
[super mouseDown:aEvent];
if ([[self cell] lastClickHoldTimedOut])
[self showFolderPopup:aEvent];
}
- (void)setItem:(BookmarkItem*)inItem
@ -220,14 +237,18 @@
if ([mBookmarkItem isGroup])
{
mIsFolder = NO;
[[self cell] setClickHoldTimeout:0.5];
[self setImage: bookmarkImage];
[self setAction: @selector(openBookmark:)];
[self setTarget: self];
}
else if ([mBookmarkItem isFolder])
{
[self setImage: bookmarkImage];
mIsFolder = YES;
[[self cell] setClickHoldTimeout:0.5];
[self setImage: bookmarkImage];
[self setAction: @selector(showFolderPopupAction:)];
[self setTarget: self];
}
else
{