From: Kent Sutherland Date: Fri, 31 Jan 2003 23:39:20 +0000 (+0000) Subject: Tabs drag only with command-drag. X-Git-Tag: v0.1~58 X-Git-Url: http://git.ithinksw.org/ITKit.git/commitdiff_plain/08f7c7656d8938806db994a646bb6e2f1a7783a7 Tabs drag only with command-drag. Added ITTabView to showcase. --- diff --git a/ITTabView.h b/ITTabView.h index 5b4795a..278238a 100755 --- a/ITTabView.h +++ b/ITTabView.h @@ -24,11 +24,15 @@ { NSTabViewItem *_draggedTab; bool _allowsDragging; + unsigned int _requiredModifiers; } - (void)setAllowsDragging:(bool)flag; - (bool)allowsDragging; +- (void)setRequiredModifiers:(unsigned int)modifiers; +- (unsigned int)requiredModifiers; + - (void)moveTab:(NSTabViewItem *)tab toIndex:(int)index; diff --git a/ITTabView.m b/ITTabView.m index 3ca1938..66f0bcc 100755 --- a/ITTabView.m +++ b/ITTabView.m @@ -17,6 +17,7 @@ if ( (self = [super initWithFrame:frame]) ) { _draggedTab = nil; _allowsDragging = NO; + _requiredModifiers = NSCommandKeyMask; } return self; } @@ -24,6 +25,7 @@ - (void)setAllowsDragging:(bool)flag { _allowsDragging = flag; + _requiredModifiers = NSCommandKeyMask; } - (bool)allowsDragging @@ -31,6 +33,16 @@ return _allowsDragging; } +- (void)setRequiredModifiers:(unsigned int)modifiers +{ + _requiredModifiers = modifiers; +} + +- (unsigned int)requiredModifiers +{ + return _requiredModifiers; +} + - (void)moveTab:(NSTabViewItem *)tab toIndex:(int)index { if ([self indexOfTabViewItem:tab] != index) @@ -44,8 +56,9 @@ - (void)mouseDown:(NSEvent *)event { - if ([self allowsDragging]) { - NSPoint clickedPoint = [self convertPoint:[event locationInWindow] fromView:[[self window] contentView]]; + if ((_requiredModifiers == 0 || ([[NSApp currentEvent] modifierFlags] & _requiredModifiers)) && [self allowsDragging]) { + NSPoint clickedPoint; + clickedPoint = [self convertPoint:[event locationInWindow] fromView:[[self window] contentView]]; NSTabViewItem *clickedTab = [self tabViewItemAtPoint:clickedPoint]; _draggedTab = clickedTab; } @@ -54,7 +67,7 @@ - (void)mouseUp:(NSEvent *)event { - if ([self allowsDragging]) { + if (_draggedTab && [self allowsDragging]) { NSPoint releasedPoint = [self convertPoint:[event locationInWindow] fromView:[[self window] contentView]]; NSTabViewItem *releasedTab = [self tabViewItemAtPoint:releasedPoint]; if (releasedTab && ![releasedTab isEqualTo:_draggedTab]) { @@ -67,7 +80,7 @@ - (void)mouseDragged:(NSEvent *)event { - if ([self allowsDragging]) { + if (_draggedTab && [self allowsDragging]) { NSPoint currentPoint = [self convertPoint:[event locationInWindow] fromView:[[self window] contentView]]; NSTabViewItem *curTab = [self tabViewItemAtPoint:currentPoint]; if (curTab && ![curTab isEqualTo:_draggedTab]) { diff --git a/Showcase/Controller.h b/Showcase/Controller.h index 0ce4bee..e1a8230 100755 --- a/Showcase/Controller.h +++ b/Showcase/Controller.h @@ -43,4 +43,11 @@ - (IBAction)hideStatusWindow:(id)sender; - (IBAction)setRotation:(id)sender; +// ITTabView support +- (IBAction)toggleTabDragging:(id)sender; +- (IBAction)toggleCommandDragging:(id)sender; +- (IBAction)toggleControlDragging:(id)sender; +- (IBAction)toggleOptionDragging:(id)sender; +- (IBAction)toggleShiftDragging:(id)sender; + @end diff --git a/Showcase/Controller.m b/Showcase/Controller.m index ee2a19c..d7808c7 100755 --- a/Showcase/Controller.m +++ b/Showcase/Controller.m @@ -20,6 +20,7 @@ { [self createStatusItem]; [testTextField setCastsShadow:YES]; + [tabView setAllowsDragging:YES]; statusWindow = [ITTransientStatusWindow sharedWindow]; // [tabView setAllowsDragging:YES]; } @@ -226,6 +227,40 @@ [statusWindow setRotation:([sender floatValue] * (pi / 180))]; } +/*************************************************************************/ +#pragma mark - +#pragma mark ITTransientStatusWindow SUPPORT +/*************************************************************************/ + +- (IBAction)toggleTabDragging:(id)sender +{ + if ([sender state] == NSOnState) { + [tabView setAllowsDragging:YES]; + } else { + [tabView setAllowsDragging:NO]; + } +} + +- (IBAction)toggleCommandDragging:(id)sender +{ + if ([sender state] == NSOnState) { + [tabView setRequiredModifiers:NSCommandKeyMask]; + } else { + [tabView setRequiredModifiers:0]; + } +} + +- (IBAction)toggleControlDragging:(id)sender +{ +} + +- (IBAction)toggleOptionDragging:(id)sender +{ +} + +- (IBAction)toggleShiftDragging:(id)sender +{ +} /*************************************************************************/ #pragma mark - diff --git a/Showcase/English.lproj/MainMenu.nib/classes.nib b/Showcase/English.lproj/MainMenu.nib/classes.nib index 880f379..2eb1c4d 100755 --- a/Showcase/English.lproj/MainMenu.nib/classes.nib +++ b/Showcase/English.lproj/MainMenu.nib/classes.nib @@ -7,9 +7,14 @@ setRotation = id; showStatusWindow = id; toggleCastsShadow = id; + toggleCommandDragging = id; + toggleControlDragging = id; toggleImage = id; toggleInvertedImage = id; + toggleOptionDragging = id; + toggleShiftDragging = id; toggleStatusItem = id; + toggleTabDragging = id; toggleTitle = id; }; CLASS = Controller; diff --git a/Showcase/English.lproj/MainMenu.nib/info.nib b/Showcase/English.lproj/MainMenu.nib/info.nib index 720d8b2..a8f0269 100755 --- a/Showcase/English.lproj/MainMenu.nib/info.nib +++ b/Showcase/English.lproj/MainMenu.nib/info.nib @@ -3,22 +3,22 @@ IBDocumentLocation - 3 3 356 240 0 0 1056 770 + 3 3 356 240 0 0 1152 746 IBEditorPositions 197 69 252 75 120 0 0 1056 770 29 - 38 293 349 44 0 0 1056 770 + 43 283 349 44 0 0 1152 746 IBFramework Version 291.0 IBOpenObjects - 29 21 + 29 IBSystem Version - 6G26 + 6G30