Expanding split view with double click
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.