• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: custom NSButtonCell behaves different/wrong on Leopard
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: custom NSButtonCell behaves different/wrong on Leopard


  • Subject: Re: custom NSButtonCell behaves different/wrong on Leopard
  • From: Mark Sanvitale <email@hidden>
  • Date: Tue, 15 Jul 2008 15:11:25 -0700

Well (much experimentation and head-scratching later), it turns out that this issue is not really a bug in Leopard, rather, it appears to be a case where a bug in Tiger allowed my buggy code to execute flawlessly on Tiger while the lack of this bug on Leopard caused the same buggy code to now exhibit buggy behavior on Leopard. True, the intention is that Tiger built apps will behave the same on Leopard, but in this case I can now understand and appreciate the discrepancy.

My custom NSButtonCell had an accessor and a setter method for getting/ setting the roll-over effect. This roll-over effect is a highlight so I named the methods isHighlighted and setIsHighlighted. Without realizing it, I had unintentionally overrode the standard NSCell method isHighlighted (while not overriding the setter method, which is named setHighlighted, i.e. no "Is").

On Tiger, this mistake has no visual effect on the button behavior, but on Leopard this makes the button appear in the pressed state on mouse-over because my custom isHighlighted, meant to indicate do-the- roll-over-effect, will mistakenly tell the standard NSButtonCell code to do-the-pressed-effect.

Thus, I guess I should write a bug against Tiger ;-)

Thanks for responding.  I'm happy to have finally figured this out.


On Jul 15, 2008, at 12:56 PM, Ken Ferry wrote:

Hi Mark,

Could you file a bug with a test app please?

There are basically two reasons for a button to display alternate content.

(1) The cell's state is not NSOffState and the showsStateBy mask
contains NSContentsCellMask.
(2) The cell is highlighted and the highlightsBy mask contains
NSContentsCellMask.

The 'button types' you see in IB (and in -[NSButtonCell
setButtonType:]) correspond to different configurations of the
showsStateBy and highlightsBy masks.  A 'momentary change' button has
NSContentsCellMask set in its highlightsBy mask and a 'toggle' button
has NSContentsCellMask in its showsStateBy mask.

-Ken

On Tue, Jul 15, 2008 at 12:39 AM, Mark Sanvitale <email@hidden> wrote:
Summary of the problem is that I have a custom NSButton subclass which
accomplishes a roll-over effect (title and background take on a special
appearance when the mouse is over the cell). On Leopard, these same cells
appear to perform a state change on mouse-over (the title and the image
switch to their alternate state), but the state has not actually changed
(according to gdb interrogation) and the title and image return to the
normal state when the mouse leaves the cell/button.


Anyone seen this problem?  Anyone know what is/could-be going wrong?

The details:

My custom NSButtonCell subclass defines some new, custom methods, and it
completely overrides drawBezelWithFrame, while it augments (i.e. still call
through to super) the methods drawInteriorWithFrame, drawTitle, and
drawImage. These cells appear in the window inside of a custom NSMatrix
subclass which does the necessary mouse event handling to accomplish
roll-over.


This all works fine and good on Tiger. On Leopard (with no code changes and
the binary compiled on either Tiger or compiled against the 10.4 sdk on
Leopard), the same button behaves wrong. The title and image being passed
into the drawTitle and drawImage state are the alternates when the mouse is
over the button, even though when I interrogate the cell in the debugger the
state has not changed (still NSOffState, i.e. the normal, not alternate
state). I can counteract the problem by ignoring the passed in title/image
and determining it myself according to the current cell state, i.e.


image = ([self state] == NSOffState) ? [self image] : [self
alternateImage];
title = ([self state] == NSOffState) ? [self attributedTitle] : [self
attributedAlternateTitle];


however, one problem still persists (beyond the obvious confusion as to why
such a tactic is even necessary) whereby the dimming of the image does not
happen on mouse-down but, rather, happens on roll-over when the button is in
the alternate state.


I'm at a loss.  Please help me.

Mark Sanvitale
Exbiblio
email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden



_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >custom NSButtonCell behaves different/wrong on Leopard (From: Mark Sanvitale <email@hidden>)
 >Re: custom NSButtonCell behaves different/wrong on Leopard (From: "Ken Ferry" <email@hidden>)

  • Prev by Date: Re: how to add modal dialog once application begin to run
  • Next by Date: Newbie: How to understand Xcode's documentation
  • Previous by thread: Re: custom NSButtonCell behaves different/wrong on Leopard
  • Next by thread: Calling an Apple Detector
  • Index(es):
    • Date
    • Thread