• 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: NSImageCells in NSMatrix - Retaining focus ring while redrawing a window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImageCells in NSMatrix - Retaining focus ring while redrawing a window


  • Subject: Re: NSImageCells in NSMatrix - Retaining focus ring while redrawing a window
  • From: Nikita Zhuk <email@hidden>
  • Date: Mon, 6 Oct 2003 20:33:49 +0300
  • Resent-date: Mon, 6 Oct 2003 20:35:41 +0300
  • Resent-from: Nikita Zhuk <email@hidden>
  • Resent-message-id: <email@hidden m>
  • Resent-to: Cocoa Dev List List <email@hidden>

It's me again,

I've almost solved my problem (by lookIng at Apple's Clock Control example, which had also focusable custom cells in a NSMatrix), and solution was pretty simple, I just had to put my focus drawing in my cell's - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView method, like this:

- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
if ([self showsFirstResponder])
[self drawFocus]; // this draws focus ring itself
[super drawWithFrame:cellFrame inView:controlView];
}

However, there's still a problem. For some reason, the control view of my cells (which is subclass of NSMatrix), does not set showsFirstResponder of cells to YES when the cell is selected with mouse click. I added a little logging to this, and noticed that control view sends always NO as value for this function (I overrided this function in my cell subclass, tested the boolean value and passed it then to the superclass):

-(void)setShowsFirstResponder:(BOOL)state
{
if (state)
NSLog(@"setShowsFirstResponder:YES");
else
NSLog(@"setShowsFirstResponder:NO");
[super setShowsFirstResponder:state];
}

So probably there's something wrong in my matrix, but I can't find the problem. The mode of my matrix is NSTrackModeMatrix. If this problem looks familiar to someone, help would be appreciated.


Greets,
Nikita


On 4.10.2003, at 12:41, Nikita Zhuk wrote:

Hi all,

I have instances of subclass of NSImageCell inside a subclass of NSMatrix, and I would like to allow user to click a cell to activate it, and draw a focus on the selected cell. Also, when user clicks somewhere else (on other cell or on empty area of the matrix), focus should be removed. I have done the focus-draw-on-click, but I'm having some problems with focus ring. It dissapears when NSMatrix is redrawn (for example, when window resizes or user minimizes and then maximizes it). Also I don't want to allow user to click emtpy cells ( cells, where [cell image] returns nil), but I can't figure it out how to do this (I have tried all modes of NSMatrix, and NSRadioModeMatrix is pretty close, but it stills highlights empty cells of the NSMatrix if user clicks them). My subclass of NSMatrix is called MTMediaMatrix, and subclass of NSImageCell is called MTMediaObject.

--
Nikita Zhuk
Mac OS & Web Developer
http://www.maczsoftware.com/blogs/nzhuk/
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: NSTextView question...
  • Next by Date: Lock Screen ?
  • Previous by thread: Re: outlet strangeness..
  • Next by thread: Lock Screen ?
  • Index(es):
    • Date
    • Thread