New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Custom NSCell drawWithFrame:inView method not getting invoked in OSX 10.8


Post Reply New Thread Subscribe

 
Thread Tools
mriganka

 
Member Since: Feb 27, 2014
Posts: 2
mriganka is on a distinguished road

mriganka is offline
I have an application where I have defined a custom cell and have overridden the method - (void) drawWithFrame:inView:

This method was drawing my custom cells without any problems as long as I was building my app using Xcode 3.2 on OS X 10.6 or older.

Now I am attempting to migrate the code to build with Xcode 4+ on OS X 10.8. And what I have found out is that my custom cell is not getting drawn anymore. After putting break points and running the app through the debugger, I realized that the overridden - (void) drawWithFrame:inView: method of the custom cell is not getting invoked at all.

My questions are:

1) What is it that makes this method to not invoke at all on OS X 10.8, while it gets invoked and works perfectly fine on OS X 10.6 or older?

2) What alternative do I have to fix this issue?

Thanks, Mriganka
QUOTE Thanks
Mark FX

 
Mark FX's Avatar
 
Member Since: Aug 13, 2011
Location: West Sussex, UK
Posts: 167
Mark FX has a spectacular aura about

Mark FX is offline
Apple's documentation advises not to invoke drawWithFrame:inView in you're own subclasses, but advises people to use the drawInteriorWithFrame:inView: method instead.

The documentation for the latest implementation of the NSCell class is listed below.

https://developer.apple.com/library/...hFrame:inView:

The reason it's not working in the later OSX versions, is because this particular NSCell method has been changed in the way it's implemented.
Once upon time this method used to be named drawWithFrameInView:, but that version has been deprecated now.

Regards Mark
QUOTE Thanks
mriganka

 
Member Since: Feb 27, 2014
Posts: 2
mriganka is on a distinguished road

mriganka is offline
According to the documentation, drawWithFrame:inView: invokes drawInteriorWithFrame:inView: after it draws the cell's border.

I tried overriding drawInteriorWithFrame:inView: in my code. That doesn't get invoked either.
QUOTE Thanks
Mark FX

 
Mark FX's Avatar
 
Member Since: Aug 13, 2011
Location: West Sussex, UK
Posts: 167
Mark FX has a spectacular aura about

Mark FX is offline
I was reading the drawInteriorWithFrame:inView: method description in the documentation, listed below, and thats where it reccomends not using the drawWithFrame:inView: method,
but if neither method is getting called then it's irrelevant anyway.

Quote:
drawInteriorWithFrame:inView:
Draws the interior portion of the receiver, which includes the image or text portion but does not include the border.

- (void)drawInteriorWithFrameNSRect)cellFrame inViewNSView *)controlView
Parameters
cellFrame
The bounding rectangle of the receiver, or a portion of the bounding rectangle.
controlView
The control that manages the cell.
Discussion
Text-type NSCell objects display their contents in a rectangle slightly inset from cellFrame using a global NSText object. Image-type NSCell objects display their contents centered within cellFrame. If the proper attributes are set, this method also displays the dotted-line rectangle to indicate if the control is the first responder and highlights the cell. This method is invoked from the drawCellInside: method of NSControl to visually update what the cell displays when its contents change. The drawing done by the NSCell implementation is minimal and becomes more complex in objects such as NSButtonCell and NSSliderCell.

This method draws the cell in the currently focused view, which can be different from the controlView passed in. Taking advantage of this is not recommended.

Subclasses often override this method to provide more sophisticated drawing of cell contents. Because drawWithFrame:inView: invokes drawInteriorWithFrame:inView: after it draws the cell's border, do not invoke drawWithFrame:inView: in your override implementation.

Availability
Available in OS X v10.0 and later.
See Also
isHighlighted
setShowsFirstResponder:
Declared In
NSCell.h
If neither method is getting called then you need to test that your NSCell subclass has been initialized properly, perhaps by checking one of it's properties in the log.

Regards Mark
QUOTE Thanks

Post Reply New Thread Subscribe


« some help with the FTP,please. | Accessing NSAlert Buttons »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Lacie HDD not detected mac OSX 10.8 berryblur Other Hardware and Peripherals 1 12-20-2012 03:58 AM
is there any usb wifi adapter?(usb lan card) working on OSX 10.8 (mountain lion)?? duredudu Other Hardware and Peripherals 3 11-18-2012 03:42 PM
My first impressions of OSX Lastmboy Switcher Hangout 32 08-08-2012 12:28 AM
Finder won't start laurag OS X - Operating System 5 04-13-2012 05:46 PM
OSX on custom machine SigNu747 OS X - Operating System 2 05-12-2009 02:06 PM

All times are GMT -4. The time now is 07:24 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?