• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Expanding split view with double click
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Expanding split view with double click


  • Subject: Expanding split view with double click
  • From: Sailesh Agrawal <email@hidden>
  • Date: Sun, 2 Feb 2003 22:45:38 -0500

In Mail.app you can double click the split view to collapse and expand it, I'm trying to write code to do the same. The code below works for collapsing the split view, but it does nothing for expanding. Any help would be greatly appreciated:

- (void) collapseView {
NSView *leftView=[[splitView subviews] objectAtIndex:0];
NSView *rightView=[[splitView subviews] objectAtIndex:1];

if (![splitView isSubviewCollapsed:leftView]) {
NSRect leftFrame=[leftView frame];
NSRect rightFrame = [rightView frame];

lastLeftWidth = leftFrame.size.width;
lastRightWidth = rightFrame.size.width;

rightFrame.size.width += leftFrame.size.width;
[rightView setFrame:rightFrame];
leftFrame.size.width = 0;
[leftView setFrame:leftFrame];
[splitView adjustSubviews];
}
}

- (void) uncollapseView {
NSView *leftView=[[splitView subviews] objectAtIndex:0];
NSView *rightView=[[splitView subviews] objectAtIndex:1];

if ([splitView isSubviewCollapsed:leftView]) {
NSRect leftFrame=[leftView frame];
NSRect rightFrame = [rightView frame];

leftFrame.size.width = lastLeftWidth;
[leftView setFrame:leftFrame];

rightFrame.size.width = lastRightWidth;
[rightView setFrame:rightFrame];

[splitView adjustSubviews];
collapsed = FALSE;
}
}

- (BOOL)splitView:(NSSplitView *)sender
canCollapseSubview:(NSView*)subview
{
if(subview == [[leftTextField superview] superview]) {
NSEvent *event = [[leftTextField window] currentEvent];
if ([event type] == NSLeftMouseDown && [event clickCount] == 2) {
if (collapsed) {
[self uncollapseView];
} else {
[self collapseView];
}
}
}
return YES;
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
  • Follow-Ups:
    • Re: Expanding split view with double click
      • From: Sailesh Agrawal <email@hidden>
  • Prev by Date: how to programatically create a document?
  • Next by Date: Cocoa/Java: Bug in NSObject.valueForKey()?
  • Previous by thread: how to programatically create a document?
  • Next by thread: Re: Expanding split view with double click
  • Index(es):
    • Date
    • Thread