• 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: NSButtonCell Ignores Button Type -- A Discovery and Annoyance
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSButtonCell Ignores Button Type -- A Discovery and Annoyance


  • Subject: Re: NSButtonCell Ignores Button Type -- A Discovery and Annoyance
  • From: Seth Willits <email@hidden>
  • Date: Tue, 29 Mar 2005 16:40:37 -0800

I have a bunch of NSButtonCells in an NSMatrix and no matter what I do, the cells toggle their states when clicked on, despite their button types being set to NSMomentaryPushInButton. I have looked at this for an hour and tried a million things, but I can't figure out why this is happening. I can setup a small test matrix and they work just fine, but mine refuses to.

A small discovery on this:

I have a custom NSButtonCell subclass which merely draws a customized button. The code for this is nothing fancy at all:


- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { // Draw Button if ([self isHighlighted] || [self state] == NSOnState) { ... Draw Highlighted } else if ([self isEnabled] == NO) { ... Draw Disabled } else { ... Draw Normal } // Draw Text ... }



When I use my custom cell, I get the toggling behavior like I said above. However if I use a normal NSButtonCell (no custom drawing), it draws and behaves as a normal push button. I add on with a category to NSButtonCell and put a break point in the setState method, and have found out that the NSButtonCell code simply ignores what the state is when drawing, and only uses [self isHighlighted]. Now, I would do this if I could, except that I elsewhere, I *do* want my cells to use a toggling behavior. I *thought* NSMatrix took care of this with the different matrix modes, but it's obvious now that it does not.


So things I don't understand about NSMatrix are:

a) How can NSMatrix have all of the selection methods and such for the NSCells is contains, if it has no affect on the visual appearance and behavior of those cells? How are *we* supposed to do that, if in fact NSMatrix doesn't?

b) Why is the sender of cell actions the NSMatrix instead of the cell? How are *we* supposed to determine which cell of a NSMatrix was clicked when this is true?

c) How can a NSButtonCell with it's button type clearly set to NSMomentaryPushInButton actually toggle in state? How are *we* supposed to stop that?





Seth Willits
------------------------------------------------------------------------ ---
President and Head Developer of Freak Software - http://www.freaksw.com
REALbasic Guru at ResExcellence - http://www.resexcellence.com/realbasic


"Yesterday we obeyed kings and bent our necks before emperors. But
today we kneel only to truth, follow only beauty, and obey only love."
-- Kahlil Gibran
------------------------------------------------------------------------ ---


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSButtonCell Ignores Button Type -- A Discovery and Annoyance
      • From: Ricky Sharp <email@hidden>
    • Re: NSButtonCell Ignores Button Type -- Hacked Solution
      • From: Seth Willits <email@hidden>
References: 
 >NSButtonCell Ignores Button Type (From: Seth Willits <email@hidden>)
 >Re: NSButtonCell Ignores Button Type (From: Stephane Sudre <email@hidden>)
 >Re: NSButtonCell Ignores Button Type (From: Seth Willits <email@hidden>)
 >Re: NSButtonCell Ignores Button Type (From: Seth Willits <email@hidden>)
 >Re: NSButtonCell Ignores Button Type (From: Ricky Sharp <email@hidden>)
 >Re: NSButtonCell Ignores Button Type (From: Ricky Sharp <email@hidden>)
 >Re: NSButtonCell Ignores Button Type (From: Seth Willits <email@hidden>)

  • Prev by Date: Re: Sharing preferences
  • Next by Date: Recommended Reading
  • Previous by thread: Re: NSButtonCell Ignores Button Type
  • Next by thread: Re: NSButtonCell Ignores Button Type -- Hacked Solution
  • Index(es):
    • Date
    • Thread