Re: Questions about NSPopupButtonCell and NSBrowser
Re: Questions about NSPopupButtonCell and NSBrowser
- Subject: Re: Questions about NSPopupButtonCell and NSBrowser
- From: "Frank D. Engel, Jr." <email@hidden>
- Date: Wed, 03 Jun 2015 19:52:52 -0400
I based my code on one of Apple's examples and had tried using
NSBrowserCell but was not able to get that working; I assume there is
some reason why Apple chose to use NSTextFieldCell in their example and
I followed suit.
Currently, I have this coded - I had tried several variations to force
the redraw and landed here but it still is not working consistently.
- (void)setImage:(NSImage *)newImage
{
//[newImage retain];
//[img release];
img = newImage;
[[self controlView] setNeedsDisplay:YES];
}
On 6/3/2015 19:39, Graham Cox wrote:
On 4 Jun 2015, at 7:29 am, Frank D. Engel, Jr. <email@hidden> wrote:
Now what I am hoping is the simpler one:
I have a custom subclass of NSTextFieldCell which I am using to show an icon in an NSBrowser. The icon image is being generated dynamically by a method in my subclass and I want it to change more or less in "real time" as a bound value changes. I have that almost working, but the one problem is that it doesn't refresh when I need it to.
Is there some way I can "force" a browser cell to redraw its image, short of redrawing the entire browser or window? The text isn't changing, just the icon, but I'd settle for redrawing the cell...
I've tried a number of things to get this working and it seems I keep coming up short.
NSBrowser normally uses NSBrowserCell to draw its content. That class has a -setImage: method which presumably knows how to mark the correct part of its host view as needing display.
If you have to use a different cell class, then you’ll need to figure out how to do the same. The cell is part of a 1-column NSMatrix which has methods to return the rect occupied by a given row, so given that you can call -setNeedsDisplayInRect: on the matrix itself. Useful methods there are -[NSMatrix getRow:column:ofCell:] and -[NSMatrix cellFrameAtRow:column:];
hth,
—Graham
_______________________________________________
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