tags:

views:

57

answers:

1

Hi guys, new here and new with cocoa. (not so good with english)

I have 2 windows one is the header [mainWindow] (setMovableByWindowBackground:YES) and the other is the content [secWindow], child of the header, the header have a button to hide the content.

[mainWindow addChildWindow:secWindow ordered:NSWindowBelow];
[mainWindow setMovableByWindowBackground:YES];

code to hide secWindow:

(IBAction) toggleSecondary: (id) sender;
{
if ([secWindow isVisible]) {
    [secWindow orderOut:self];
} else {        
    [secWindow orderFront:self];
}
}

the problem is when a push the button, all app hide, Main and Sec windows and only need to hide the [secWindow].

This app was develop for another team, now is in my hands... Any advice will be well received.

A: 

Weel, I found a solution, I don't know if a correct way, but works for me. ^_^

//get the mainWindow cordinates
NSRect theFrame = [mainWindow frame];
NSPoint theOrigin = theFrame.origin;
NSPoint pSecWin = theFrame.origin;
//put secWin below mainWindow
pSecWin.y = theOrigin.y - secHeight;

(IBAction) toggleSecondary: (id) sender;
{
if ([secWindow isVisible]) {
    [mainWindow removeChildWindow:secWindow];
    [secWindow orderOut:self];
} else {  
    [secWindow setFrameOrigin:pSecWin];
    [mainWindow addChildWindow:secWindow ordered:NSWindowBelow];      
    [secWindow orderFront:self];
}
}

so thats it, thanks anyway

turco