MobX
MobX

Reputation: 2670

Cannot hide Controls in NSView

I am developing an application in cocoa. Now I am facing a critical issue. I can't hide controls NSButton in NSView. I used the following code

[btn setHidden:YES]

but this "btn" control is not becoming hidden. I used the following code to check whether the button is hidden

[btn isHidden]

but this return YES. Also I can't sent a value to NSTextfield while showing this view.

Thanks in advance.

Upvotes: 0

Views: 1374

Answers (2)

Jon Steinmetz
Jon Steinmetz

Reputation: 4124

Without knowing what else is going on in the application it is hard to know why this would not be making the button hidden.

Are you blocking the main event loop such that the update events are not getting handled? Generally this is not a good thing to do.

One thing you can do to force an immediate update is to call displayIfNeeded on the button or its parent view or window. This should cause the view to be redrawn. This would be suitable as an experiment to validate that the button will draw (or not draw) its correct state. If calling displayIfNeeded does cause it to disappear then you will need to determine why update events are not getting handled correctly.

Upvotes: 1

diederikh
diederikh

Reputation: 25271

Please try running the runloop once after hiding the button:

 [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]];

Upvotes: 1

Related Questions