Rodrigo Rivera
Rodrigo Rivera

Reputation: 177

How to change NSCarbonWindow visibility?

I'm using ::RunAppModalLoopForWindow(WindowPtr) to run a carbon window as modal. But at some point I need to show/hide all application's windows with:

NSArray* windowNumbers = [NSWindow windowNumbersWithOptions:0];

for (NSNumber* windowNumber in windowNumbers)
{
    NSWindow* window = [[NSApplication sharedApplication] windowWithWindowNumber:[windowNumber integerValue]];

        [window setAlphaValue:CGFloat(showFlag)];
}

But window is NSCarbonWindow* that does not respond to setAlphaValue, and thus, the window is not changing its visibility.

Also, I don't know where NSCarbonWindow is defined so I can cast from NSWindow to NSCarbonWindow.

Upvotes: 0

Views: 147

Answers (1)

JWWalker
JWWalker

Reputation: 22707

How about:

if ([window respondsToSelector: @selector(setAlphaValue:)])
    [window setAlphaValue:CGFloat(showFlag)];
else if (showFlag)
    ShowWindow( [window windowRef] );
else
    HideWindow( [window windowRef] );

Upvotes: 1

Related Questions