Thanks! This is the kind of info I'm looking for.

The problem that I always run into is that the documentation doesn't
explain how and when to use these states. For example, the docs for
isHighlighted on NSCell reads "Returns a Boolean value that indicates
whether the receiver is highlighted.". Which could mean so many
things, and is somewhat hard to interpret as "use this to draw
something if the mouse is down." That's just me though, and this is my
first pass at actually using a cell.. So far not too bad.



On Tue, May 11, 2010 at 10:08 PM, Graham Cox <graham....@bigpond.com> wrote:
> A further thought - why are you trying to do a hit-test during a drawing 
> method anyway?
>
> If your aim is to perform some highlighting during tracking, then the cell 
> has well-defined methods and states for determining when to do that. This 
> hit-testing is performed when the cell is being tracked in response to the 
> mouse down/mouse dragged/mouse up events (NSCell factors these into further 
> methods) which sets the appropriate state and calls for a refresh using the 
> standard drawing mechanism. Your draw method should be examining these states 
> (via methods such as as -isHighlighted, etc) and drawing appropriately.
>
> I don't believe you can reliably hit-test during drawing even if you wanted 
> to, because the current event at that time is not a mouse event.
>
> --Graham
>
>
>
>
>
> On 12/05/2010, at 3:01 PM, Graham Cox wrote:
>
>>
>> On 12/05/2010, at 2:51 PM, aaron smith wrote:
>>
>>> To me the first "localPoint = ..." should be the correct way to
>>> convert the windowPoint to the control views' coordinate space. But
>>> it's never right.
>>>
>>> Any ideas?
>>
>>> localPoint = [[self controlView] convertPoint:windowPoint toView:nil];
>>
>>
>> You're working way too hard. Also, your first localPoint= is exactly the 
>> wrong way around. It should be:
>>
>>
>> NSPoint localPoint = [controlView convertPoint:[event locationInWindow] 
>> fromView:nil];
>>
>> that should be all you need to do. As I understand it, a cell's -controlView 
>> method might not return the control view reliably, so you are better off 
>> using the view passed to the method as a parameter.
>>
>> All that convertScreenToBase stuff you're doing is superfluous AFAICS.
>>
>> --Graham
>
>
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to