Commits

Virgil Dupras committed 6b3601c

After a tab drag&drop, only restore selection after the delegate has been notified of the move. Also, added cellForTab: method.

  • Participants
  • Parent commits 5078939

Comments (0)

Files changed (2)

File PSMTabBarControl.h

 - (id)partnerView;
 - (void)setPartnerView:(id)view;
 - (PSMTabBarCell *)cellAtIndex:(NSInteger)index;
+- (PSMTabBarCell *)cellForTab:(NSTabViewItem *)tabItem;
 
 // the buttons
 - (PSMRolloverButton *)addTabButton;

File PSMTabBarControl.m

     return [_cells objectAtIndex:index];
 }
 
+- (PSMTabBarCell *)cellForTab:(NSTabViewItem *)tabItem
+{
+    for (PSMTabBarCell *cell in _cells) {
+        if ([cell representedObject] == tabItem) {
+            return cell;
+        }
+    }
+    return nil;
+}
+
 #pragma mark -
 #pragma mark Drawing
 
        there are more tab cells than NSTabViewItems. So what we do after having moved the cell is we
        look at all cells following destIndex and stop at the first one that has a representedObject
        (a NSTabViewItem). Then, we can know where to insert our tab.
-     */
+    */
     NSTabViewItem *draggedTab = [aCell representedObject];
     NSTabViewItem *targetTab = nil;
     NSInteger destIndex = [[self cells] indexOfObject:aDropCell];
     }
     [[aSourceBar tabView] setDelegate:aSourceBar];
     [[self tabView] setDelegate:self];
-    if (wasSelected) {
-        [[self tabView] selectTabViewItem:draggedTab];
-    }
     
     if (([self delegate]) && ([[self delegate] respondsToSelector:@selector(tabView:movedTab:fromIndex:toIndex:)])) {
         [[self delegate] tabView:[self tabView] movedTab:draggedTab fromIndex:fromIndex toIndex:destIndex];
     }
+    
+    if (wasSelected) {
+        [[self tabView] selectTabViewItem:draggedTab];
+    }
 }
 
 #pragma mark -