Thanks Robert. The usefulness is the ability to provide a customized toolbar like in many other applications and restore the settings the customer last made. Imagine the Finder giving you the ability to customize your Windows but the next time you open a window, your custom settings are gone and revert to the defaults. On May 7, 2011, at 8:27 PM, Robert Purves wrote: > > Steve wrote: > >> I have a NIB window with a toolbar. How do I open a window and NOT display the toolbar, but show it in the collapsed state? >> I am using the Fn ToolbarCreate in Util_toolbar.incl > > The third parameter of ToolbarAttachToWindow() governs the initial visibility of the toolbar. > >> Are there any examples showing how to track customization of a default toolbar? For example, a user adds an icon to Print in the toolbar, but its not part of the default configuration. > > I don't see the usefulness, but you can install a handler on the toolbar for {_kEventClassToolbar, _kEventToolbarItemAdded}. > > Robert P. > > > '----------------- > include "Util_Toolbar.incl" > > local fn ToolbarItemAddedHandler( inCallRef as EventHandlerCallRef, inEvent as EventRef, userData as pointer ) > '~'1 > dim as HIToolbarRef toolbar : toolbar = userData > > beep > print "Item was added > end fn = _eventNotHandledErr > > > local fn InstallToolbarItemAddedHandler( w as WindowRef ) > '~'1 > dim as HIToolbarRef toolbar > dim as EventTypeSpec eventSpec > > long if ( fn GetWindowToolbar( w, @toolbar ) == _noErr ) > eventSpec.eventClass = _kEventClassToolbar > eventSpec.eventKind = _kEventToolbarItemAdded > fn InstallEventHandler( fn GetControlEventTarget( (HIViewRef)toolbar ), @fn ToolbarItemAddedHandler, 1, @eventSpec, #toolbar, 0 ) > end if > end fn > > > local fn BuildToolbar( toolbarID as UInt8 ) > '~'1 > fn ToolbarCreate( toolbarID, fn CFSTR( "com.mycompany.myapp.tbar" ), _kHIToolbarIsConfigurable ) > fn ToolbarItemSetDefault( toolbarID, kHIToolbarCustomizeIdentifier ) > fn ToolbarItemSetAllowed( toolbarID, kHIToolbarPrintItemIdentifier ) > end fn > > > local fn BuildWindow( wNum as long, toolbarID as UInt8 ) > '~'1 > appearance window wNum, "demo",, _kDocumentWindowClass, _kWindowToolbarButtonAttribute > //fn ToolbarAttachToWindow( toolbarID, window( _wndRef ), _true ) > fn ToolbarAttachToWindow( toolbarID, window( _wndRef ), _false ) // hidden > fn InstallToolbarItemAddedHandler( window( _wndRef ) ) > print "Click toolbar button, then Customize, then drag Print item to toolbar > end fn > > > _myToolBarID = 0 > fn BuildToolbar( _myToolBarID ) > fn BuildWindow( 1, _myToolBarID ) > RunApplicationEventLoop() > '----------------- > > > > > > > > -- > To unsubscribe, send ANY message to: futurebasic-unsubscribe@... > To access the list archives, go to: http://freegroups.net/groups/futurebasic/ >