views:

21

answers:

2

I'm trying to build a resizable Carbon window as part of a tutorial. I am using Interface Builder 3.2.3 on Snow Leopard 10.6.4.

If I create an empty Carbon project and add a window object from the Library (with Close, Minimize, Resize and Zoom buttons in the Inspector all checked), run the Carbon Simulator and then attempt to resize the window by grabbing the resize control, the window vanishes.

However if I create a Carbon project that already has the window object included (i.e instead of an empty project where I add the window myself after first creating it) I have no problem resizing the window in that case.

I try to visually match the selections in the Inspector to see what is different between the settings of these two cases but I don't readily notice any differences in the two sets of parameters that are displayed. Thus I am curious as whether there are more settings that just aren't displayed on the Inspector.

Are there any common reasons for a Carbon window to vanish upon resizing?

Thanks

A: 

I notice that if the option to receive clicks is not checked, then the window goes away when you try to resize it. But I don't know how you could uncheck that accidentally.

JWWalker
A: 

JWWalker, thanks for the response. Receive Clicks was checked on both versions.

But I think I was able to (sort of) figure out the discrepancy examining the .nib file.

Both files have two keys defined: maxSize (under com.apple.ibtool.document.localizable-all) and gMaxSize (under com.apple.ibtool.document.objects). In the working file both of these have a string setting of {480, 270}. In the nonworking file they had a string setting of {0, 0}. Apparently the default configuration of the working file was setting the maximum size of the window equal to zero. In Inspector the Window Template Size tab had the "Maximum Size" box checked but a "0" for both Width and Height. I clicked the box once to clear the check. Ran the Carbon Simulator again and the window resized properly without disappearing. When I rechecked the box, Inspector automatically filled in the Width and Height parameters with valid values of 480 and 270. I ran the Carbon Simulator again and it resized properly in accordance with the new maximum size constraint.

I don't fully understand the XML code in the .nib file but apparently the default setting for the maximum size of the window was being set to zero. The incorrect code appeared in the .nib file as follows (with non relevant lines deleted):

com.apple.ibtool.document.localizable-all

<dict>
    <key>1</key>
    <dict>
        <key>maxSize</key>
        <string>{0, 0}</string>

com.apple.ibtool.document.objects

<dict>
    <key>1</key>
    <dict>
        <key>gMaxSize</key>
        <string>{0, 0}</string>
Mike