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?
4 Answers
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];
}
}
}

- 3,550
- 3
- 35
- 51
You could try something like:
[someWindow setAlpha:0.5]; // you can change this number to you visual taste.
[someWindow setIgnoresMouseEvents:YES];
-
1maybe this was different in 2012, but in 2014, calling -setIgnoresMouseEvents:YES causes clicks to go through the window. They are not just ignored, but the click will be forwarded to the window that is behind it in the desktop (OS X 10.10) – Michael Jan 07 '15 at 11:37
-
Agreed. That worked in previous versions of OS X but doesn't now. Also, I'd actually suggest @mmackh's answer below as a better approach. – mdominick Jan 10 '15 at 22:23
Since the first answer would still allow keyboard inputs, I would make it clean and walk trough each UI element in a loop and set it to disabled in addition to make the window half visible. (Edit: mmackh's answer has the code to do this.)
Or you you use the easy way and simply add an invisible NSView
on top of your window that is firstResponder and "catches" all inputs.

- 3,032
- 2
- 37
- 54
As a different option, one can have a hidden window with NSMakeRect(0,0,10,0) height 0 and write a disableWindow method in the windowController or window subclass that throws a panel with the above hidden window. On opening the panel the screen will be disabled. enableWindow would alternatively orderOut the above stated hiddenWindow re-enabling the main window.

- 102
- 7