From: Tim P. <he...@ti...> - 2007-05-30 08:13:27
|
Hey Eloy Sure, here is my code for the toolbar (which is in the same window controller): def setupToolbar #NSLog("start toolbar methods") # Create a new toolbar instance, and attach it to our document window. @toolbar ||= NSToolbar.alloc.initWithIdentifier(TB_IDENTIFIER) # Set up toolbar properties: Allow customization, give a default display mode # and remember state in user defaults. @toolbar.setAllowsUserCustomization(true); @toolbar.setAutosavesConfiguration(true); @toolbar.setDisplayMode(NSToolbarDisplayModeIconAndLabel) # We are the delegate. @toolbar.setDelegate(self) window = self.window # Attach the toolbar to the document window. window.setToolbar(@toolbar) end def toolbarDefaultItemIdentifiers(toolbar) [ TB_SERVER_CONNECTION, TB_LOG_DRAW, TB_SEND_HTTP, NSToolbarFlexibleSpaceItemIdentifier, NSToolbarPrintItemIdentifier ] end def toolbarAllowedItemIdentifiers(toolbar) [ NSToolbarPrintItemIdentifier, NSToolbarCustomizeToolbarItemIdentifier, NSToolbarFlexibleSpaceItemIdentifier, NSToolbarSpaceItemIdentifier, NSToolbarSeparatorItemIdentifier, TB_SERVER_CONNECTION, TB_LOG_DRAW, TB_SEND_HTTP ] end def toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar(toolbar, identifier, flag) label, tooltip, image, action = case identifier.to_s when TB_SERVER_CONNECTION [ "Server Connection", "Display all avalible output devices", "connect", 'showConnectionSheet:' ] when TB_LOG_DRAW [ "Output Pannel", "Display output log", "sidebar", 'toggleLogDraw:' ] when TB_SEND_HTTP [ "Send Requests", "Send requests to server", "go", 'sendRequestMessages:' ] else return nil end toolbarItem = NSToolbarItem.alloc.initWithItemIdentifier (identifier) toolbarItem.setLabel(label) toolbarItem.setPaletteLabel(label) toolbarItem.setToolTip(tooltip) toolbarItem.setImage(NSImage.imageNamed(image)) toolbarItem.setTarget(self) toolbarItem.setAction(action) return toolbarItem end I think this is pretty bog standard methodology for setting up the toolbar? Any help you can give would be brilliant :) Cheers Tim On 30 May 2007, at 08:25, rubycocoa-talk- re...@li... wrote: > Hey Tim, > > Could you maybe post some more detail about how you setup the toolbar? > > Cheers, > Eloy |