2008 11 26Painting Up There
The Cocoa View hierarchy only talks about the hierarchy of controls in the content view, laid out in Interface Builder. That view hierarchy also extends up — the content view is hosted by a frame view which paints the window itself : background, title, shadow. That frame view is the parent of the window Close/Minimize/Maximize controls and of the toolbar show/hide control.
- Painting in the title bar retrieve the frame view with
[[window contentView] superview]and reparent your control with
[frameView addSubview:myControl]. Why do that ? I never felt the help button in JSCocoa's console was well placed. Putting it up there seems to make more sense. As the toolbar is minimal and non customizable, the show/hide toolbar button won't be missed.
- Painting in the toolbar retrieve the frame view and look for its child of class
NSToolbarView. Reparent your control to it with
addSubview. Why do that ? I wondered how iTunes paints its 'toolbar' controls. It looks like a toolbar on the right side, but the center HUD and left side play controls don't have labels. Why not use a toolbar to have the standard appearance and fill the missing parts with raw views ? Don't know if it's a good solution, but it works.
Sample Code Painting Up There.zip
With once again thanks to F-Script for all the spying.