开发者

Hide child controls in an NSView

I have an NSView with multiple child controls in it. I know I can call [childControl setHidden:TRUE] but I was wondering if its possible to block the message "drawRect:" for the child controls.

Ive noticed that not calling [super drawRect:NSZeroRect] on the NSView does not affect the child controls. So my question is who calls the child controls drawRect message? And if there is a way to block开发者_StackOverflow中文版 it.

Thanks, Jose.


Every time the controls should react optically, they draw its view again. If you really want to solve this problem like that, you can create for each control a subclass and add a code like this:

-(void)drawRect:(NSRect)rect {
if (!self.blocked) {
[super drawRect:rect];
}
}

The property "blocked" is a boolean which you have to set to YES or NO if you want to block it. Note: To totally hide it the control subclass has to be blocked before it draws it self the first time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜