Hi Quincey, Jeff, -[NSButtonCell setButtonType:] is (mostly) a cover for certain combinations of -[NSButtonCell setHighlightsBy:] and -[NSButtonCell setShowsStateBy:].
For a button, highlighted is synonymous with "pressed". setHighlightsBy: controls how a button draws to communicate that it is pressed. It takes an NSCellMask describing the look. showsStateBy: describes how a button should draw to show that it's "on". _All_ buttons change from on to off and back when clicked, it's just that many do not show it. This is also described with an NSCellMask. NSCellMask is a combination of NSContentsCellMask, NSPushInCellMask, NSChangeGrayCellMask, and NSChangeBackgroundCellMask. 0 is also a possibility, which would mean "do not draw differently". NSContentsCellMask means "use alternate contents", i.e. -[NSButtonCell alternateImage] and -[NSButtonCell alternateTitle]. NSPushInCellMask means "look pushed in". NSChangeGrayCellMask and NSChangeBackgroundCellMask are rather historical names (the first comes from the NeXT's four color display - it refers to swapping one of the two gray colors with the other one!). They basically mean, uh, draw the bezel differently in some fashion. Anyway, NSMomentaryLightButton sets highlightsBy to NSChangeGrayCellMask|NSChangeBackgroundCellMask and showsStateBy to 0. NSMomentaryPushInButton sets highlightsBy to NSPushInCellMask and showsStateBy to 0. NSPushOnPushOffButton sets highlightsBy to NSPushInCellMask | NSChangeGrayCellMask|NSChangeBackgroundCellMask and showsStateBy to NSChangeGrayCellMask|NSChangeBackgroundCellMask. NSOnOffButton sets highlightsBy to NSChangeGrayCellMask|NSChangeBackgroundCellMask and showsStateBy to NSChangeGrayCellMask|NSChangeBackgroundCellMask. I find direct use of showsStateBy and highlightsBy to mostly make more sense than setButtonType. -Ken On Wed, Oct 27, 2010 at 9:13 PM, Quincey Morris <quinceymor...@earthlink.net > wrote: > On Oct 27, 2010, at 20:04, Jeff Johnson wrote: > > > I was aware of the documentation, and you appear to have it backwards: > > > > NSMomentaryLightButton > > While the button is held down it’s shown as “lit,” and also “pushed in” > to the screen if the button is bordered. > > > > NSMomentaryPushInButton > > While the button is held down it’s shown as “lit.” > > > > Nonetheless, one would expect that NSMomentaryPushInButton would also be > pushed in, given its name. And as I said, there seems to be no difference in > behavior. > > You're right, I read it according my expectation, not according to the > actual words. :) > > This is very strange, though. According to this document, > NSMomentaryPushInButton is the behavior of a normal push-button, and we know > it *is* shown as pushed-in (for at least some of the bordered button types). > Also, here's what the Leopard release notes had to say about it: > > > The constants NSMomentaryPushButton and NSMomentaryLight where reversed. > If you called [NSButtonCell setButtonType:] with these constants, they would > do the wrong thing. For compatability, these constant names have been kept > but new ones with the correct naming have been introduced: > NSMomentaryLightButton and NSMomentaryPushInButton. > > After playing around with IB's simulator for a bit, I couldn't find a case > where the two non-deprecated constants made any visual difference, either -- > regardless of the presence of a template image. I have a vague recollection > of finding a difference between them, in the past, but it's possible that > I'm just remembering reading the documentation and believing what it said. > > It's possible that there's technically a difference between the two types, > but that no bezel formats currently show the difference visually. > > Very strange. > > > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > http://lists.apple.com/mailman/options/cocoa-dev/kenferry%40gmail.com > > This email sent to kenfe...@gmail.com > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com