I'm not sure that there's some system-level feature like that. Anyway, is there a way to make NSWindow looks disabled and does not respond to user input?
I don't think mdominick's answer is correct. Since I only wanted to disable the NSTextFields and NSButtons, I came up with this:
for (NSView *item in [self.window.contentView subviews])
{
if ([item isKindOfClass:[NSTextField class]] || [item isKindOfClass:[NSButton class]])
{
[(id)item setEnabled:NO];
}
}
EDIT
Whilst working on a new app, this method in a subclass of NSWindow was really convenient
- (void)setEnabled:(BOOL)enabled
{
[self setEnabled:enabled view:self.window.contentView];
}
- (void)setEnabled:(BOOL)enabled view:(id)view
{
if ([view isHidden]) return;
for (NSView *item in [view subviews])
{
if ([item isKindOfClass:[NSProgressIndicator class]])
{
NSProgressIndicator *pI = (NSProgressIndicator *)item;
[pI setHidden:enabled];
if (!enabled) [pI startAnimation:nil];
if (enabled) [pI stopAnimation:nil];
}
if ([item isKindOfClass:[NSTextField class]] || [item isKindOfClass:[NSButton class]] || [item isKindOfClass:[NSTextView class]])
{
[(id)item setEnabled:enabled];
continue;
}
if (item.subviews.count)
{
[self setEnabled:enabled view:item];
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With