Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSTextField click-through?

I have a static NSTextField that overlays a large error message in my OS X app. I'm trying to get it to allow the user to click controls beneath it.

In IB I've unchecked "enabled" and I've checked "Refuses First Responder"

I've also done it in code because that wasn't working:

[largeErrorText setEnabled:NO];
[largeErrorText setRefusesFirstResponder:YES];

Still, it is getting in the way of interacting with the objects below it. Any ideas what else it might be?

like image 440
olynoise Avatar asked Apr 09 '13 00:04

olynoise


1 Answers

The only way I have found to make an object transparent to the click is to subclass that object (in your case the NSTextField) and override the hitTest method returning nil. This way that NSTextField will not respond to the click so the NSView below will respond to the click.

- (NSView*)hitTest:(NSPoint)aPoint
{
    return nil;
}
like image 97
Leonardo Avatar answered Oct 20 '22 07:10

Leonardo