Nat! bio photo

Nat!

Senior Mull.

Twitter RSS

Github

The lameness of NSSegmentedControl

If you have an NSSegmentedControl on a pallete with some images in it, you are bound for trouble. The problem is, that the image data of each cell isn't encoded along with the rest of the cell information. Rather the cell encodes the pathname of the image. That sounds good at first, because you don't end up with a lot of duplicate images. This is bad, because it is the absolute path of the image:

       <string>/Library/Developer/Palettes/XXXInterfacePalette.palette/Contents/Resources/FormSel_5.tiff</string>
       <dict>
               <key>$class</key>
               <dict>
                       <key>CF$UID</key>
                       <integer>30</integer>
               </dict>
               <key>NSSegmentItemDisabled</key>
               <true/>
               <key>NSSegmentItemImage</key>
               <dict>
                       <key>CF$UID</key>
                       <integer>37</integer>
               </dict>
               <key>NSSegmentItemLabel</key>
               <dict>
                       <key>CF$UID</key>
                       <integer>29</integer>
               </dict>
               <key>NSSegmentItemTag</key>
               <integer>2</integer>
               <key>NSSegmentItemWidth</key>
               <real>27</real>
       </dict>

Obviously in a deployment scenario your image will not be found, if the palette isn't there.