Tabs drag only with command-drag.
authorKent Sutherland <ksuther@ithinksw.com>
Fri, 31 Jan 2003 23:39:20 +0000 (23:39 +0000)
committerKent Sutherland <ksuther@ithinksw.com>
Fri, 31 Jan 2003 23:39:20 +0000 (23:39 +0000)
Added ITTabView to showcase.

ITTabView.h
ITTabView.m
Showcase/Controller.h
Showcase/Controller.m
Showcase/English.lproj/MainMenu.nib/classes.nib
Showcase/English.lproj/MainMenu.nib/info.nib

index 5b4795a..278238a 100755 (executable)
 {
     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;
 
 
index 3ca1938..66f0bcc 100755 (executable)
@@ -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
     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]) {
index 0ce4bee..e1a8230 100755 (executable)
 - (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
index ee2a19c..d7808c7 100755 (executable)
@@ -20,6 +20,7 @@
 {
     [self createStatusItem];
     [testTextField setCastsShadow:YES];
+    [tabView setAllowsDragging:YES];
     statusWindow = [ITTransientStatusWindow sharedWindow];
 //  [tabView setAllowsDragging:YES];
 }
     [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 -
index 880f379..2eb1c4d 100755 (executable)
@@ -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; 
index 720d8b2..a8f0269 100755 (executable)
@@ -3,22 +3,22 @@
 <plist version="1.0">
 <dict>
        <key>IBDocumentLocation</key>
-       <string>3 3 356 240 0 0 1056 770 </string>
+       <string>3 3 356 240 0 0 1152 746 </string>
        <key>IBEditorPositions</key>
        <dict>
                <key>197</key>
                <string>69 252 75 120 0 0 1056 770 </string>
                <key>29</key>
-               <string>38 293 349 44 0 0 1056 770 </string>
+               <string>43 283 349 44 0 0 1152 746 </string>
        </dict>
        <key>IBFramework Version</key>
        <string>291.0</string>
        <key>IBOpenObjects</key>
        <array>
-               <integer>29</integer>
                <integer>21</integer>
+               <integer>29</integer>
        </array>
        <key>IBSystem Version</key>
-       <string>6G26</string>
+       <string>6G30</string>
 </dict>
 </plist>