Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
# # PreferencesController.rb # Example Preferences Window Controller # # Created by Matthew McCray on 12/23/07. # Copyright (c) 2008 Matthew McCray, Elucidata (www.elucidata.net) # require 'osx/cocoa' class PreferencesController < OSX::NSWindowController include OSX # This is the target action for the toolbar items ib_action :selectPrefPanel do |sender| # We'll do stuff here later... end def init self if self.initWithWindowNibName_owner('Preferences', self) end # Delegate method that returns the itemIdentifiers for the selectable items # (in our case, all of 'em) def toolbarSelectableItemIdentifiers(toolbar) @toolbaritemidents ||= begin window.toolbar.items.map {|item| item.itemIdentifier } end end # Select the first toolbar item when the window loads def windowDidLoad window.toolbar.selectedItemIdentifier = window.toolbar.items[0].itemIdentifier end end
From the Design Piracy series on my blog: