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开发者_如何学Python 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].
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
精彩评论