• 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 -- Hacked Solution
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSButtonCell Ignores Button Type -- Hacked Solution


  • Subject: Re: NSButtonCell Ignores Button Type -- Hacked Solution
  • From: Seth Willits <email@hidden>
  • Date: Tue, 29 Mar 2005 17:23:24 -0800

Sorry for the noise, but I've hacked my way into a solution that works for me that I thought I'd shared, and hopefully someone will think it's ugly and post a better one.


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?

In a NSButtonCell subclass, I have:

- (void)setState:(int)state
{
	MyCustomMatrix * matrix = (MyCustomMatrix *)[self controlView];
	if ([matrix inSelectionMode]) {
		[super setState:state];
		return;
	}
	[super setState:0];
}


[matrix inSelectionMode] is a boolean dictating whether a cell can be selected or not. This probably should be changed to work off of the button type, but it would have required more code in my specific case, so I did it this way.




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?

I still have no idea why, but here's the solution. In an NSCell subclass:


- (void)_sendActionFrom:(id)sender
{
[[NSApplication sharedApplication] sendAction:[self action] to:[self target] from:self];
}


*This* code requires that you set the action for each cell (they can be the same, no worries there), though it could be written differently.



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?

I have no idea why this is, but see the solution to a.



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


"Your friend is the person who knows all about you and still likes you."
-- Elbert Green Hubbard
------------------------------------------------------------------------ ---


_______________________________________________
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


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>)
 >Re: NSButtonCell Ignores Button Type -- A Discovery and Annoyance (From: Seth Willits <email@hidden>)

  • Prev by Date: [Moderator] Cocoa and list resources
  • Next by Date: Re: Recommended Reading
  • Previous by thread: Re: NSButtonCell Ignores Button Type -- A Discovery and Annoyance
  • Next by thread: Re: NSButtonCell Ignores Button Type -- A Discovery and Annoyance
  • Index(es):
    • Date
    • Thread