how to show hidden object?

i have a strange little problem in an app I am creating.
I need to have interface object (namely some boxes) hidden as launch but become visible later on.
I would have thought this would be possible by simply setting the object to be hidden in interface builder then making it visible with a line of code like…

set visible of box “thebox” to true

but that doesn’t seem to work.
I also tried setting the visibility of the objects to false on awake from nib but that is nasty as that object are momentarily visible when the window opens.
Surely there is a way to do this?

I think I know the problem you are having. Don’t make the objects hidden. Rather set their visible property to false at startup before you make there parent window visible. Then make them visible true when you want them seen. Hidden and visible are different properties.

The “hidden” property has nothing to do with the “visible” property. Although at a fundamental cocoa level applescript may call on the same methods used by cocoa to hide and unhide views, setting the visible property of an object has no effect on an object marked as “hidden” in IB. Once it is hidden, only calls to unhide it using obj-c will actually make the object visible again. You should stick to using only the AS “visible” property, and leave the ‘hidden’ value alone and unchecked in IB.

Doing initializations of objects can be done in the awake from nib handler, but it may not be reasonable for this particular one. The box does not ‘technically’ awaken until it’s being displayed… making it too late to set it’s visibility without that flash of visibility. You could use the awake from nib of the window, but that may still cause problems.

In a case like this, I prefer to use the ‘will open’ handler of the window containing the object. Any code placed in it will be sure to be executed before the window is actually drawn. If you only want the items to be invisible the first time the window opens, then use a property variable to keep track of whether it’s the first run of not.

property isFirstRun : true

on will open theObject
	if name of theObject is "window" then
		if isFirstRun then
			tell box "box" of theObject to set visible to false
			set isFirstRun to false
		end if
	end if
end will open

Hope that’s what your looking for.
j

thanks, it all works now :slight_smile: