2009-12-20 32 views
2

Bonjour, Je dois implémenter quatre répartiteurs de vue comme dans Maya, 3ds max, Blender ou d'autres outils de modélisation similaires. J'utilise NSSplitView du côté Mac de mon éditeur et j'ai besoin de savoir quand l'utilisateur déplace un volet pour synchroniser un autre volet.
Est-il possible d'obtenir une nouvelle taille à partir d'un NSSplitView et de lui synchroniser une autre vue? J'ai le code de travail pour Windows Forms dans la version C# de cet éditeur, mais je ne peux pas comprendre comment le faire sur un Mac. Le code source complet est à .Notification de modification du volet séparateur NSSplitView

Merci beaucoup.

Répondre

4

Je l'ai fixé avec ce code:

- (void)splitViewDidResizeSubviews:(NSNotification *)notification 
{ 
    NSSplitView *splitView = (NSSplitView *)[notification object]; 
    NSView *topSubview0 = (NSView *)[[topSplit subviews] objectAtIndex:0]; 
    NSView *topSubview1 = (NSView *)[[topSplit subviews] objectAtIndex:1]; 

    NSView *bottomSubview0 = (NSView *)[[bottomSplit subviews] objectAtIndex:0]; 
    NSView *bottomSubview1 = (NSView *)[[bottomSplit subviews] objectAtIndex:1]; 

    if (fabsf([bottomSubview0 frame].size.width - [topSubview0 frame].size.width) >= 1.0f) 
    { 
     if (splitView == topSplit) 
     { 
      NSLog(@"topSplit"); 
      [bottomSubview0 setFrame:[topSubview0 frame]]; 
      [bottomSubview1 setFrame:[topSubview1 frame]]; 
     } 
     else 
     { 
      NSLog(@"bottomSplit"); 
      [topSubview0 setFrame:[bottomSubview0 frame]]; 
      [topSubview1 setFrame:[bottomSubview1 frame]]; 
     } 
    } 
}