• 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: Cocoa window messages in app being ported from Carbon
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa window messages in app being ported from Carbon


  • Subject: Re: Cocoa window messages in app being ported from Carbon
  • From: Uli Kusterer via Cocoa-dev <email@hidden>
  • Date: Sat, 10 Aug 2019 23:42:38 +0200

> On 10. Aug 2019, at 23:21, Rob Petrovec via Cocoa-dev
> <email@hidden> wrote:
>
>> On Aug 10, 2019, at 3:12 PM, Kurt Bigler <email@hidden> wrote:
>>
>> On 8/10/19 10:03:00 AM, Rob Petrovec wrote:
>>>> On Aug 10, 2019, at 12:24 AM, Kurt Bigler via Cocoa-dev
>>>> <email@hidden> wrote:
>>>>
>>>> The NSView subclasses involved are receiving drawRect: messages but are
>>>> not receiving mouseDown:.
>>
>>>     You need to implement NSView -hitTest: to get mouseDown events.
>>
>> I have 5 working Cocoa apps, and none implement hitTest.  It is apparently
>> needed for special circumstances, per the docs "to have a view object hide
>> mouse-down events from its subviews”.
>       The OP said NSView subclasses.  Not NSControl.  So he needs to
> implement hitTest to get mouseDown events.  If you read the sentence before
> the line you quoted:  "This method is used primarily by an NSWindow object to
> determine which view should receive a mouse-down event.”.  NSView returns nil
> from hitTest by default, so raw NSViews don’t get mouseDown events.
>
> —Rob

Have you actually tried creating a custom NSView, because this is simply not
the behavior I've observed in the last 10+ years as a Cocoa UI programmer.

The only reason to override hitTest is if you want a view through which clicks
pass through under certain circumstances (i.e., it has a non-rectangular shape
or a built-in shadow through which clicks should pass to underlying views) or
if you want to handle clicks that are actually destined for one of your sub
views.

A plain NSView will do all the correct hit-testing for subviews and itself by
default.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de

_______________________________________________

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

References: 
 >Cocoa window messages in app being ported from Carbon (From: Kurt Bigler via Cocoa-dev <email@hidden>)
 >Re: Cocoa window messages in app being ported from Carbon (From: Rob Petrovec via Cocoa-dev <email@hidden>)
 >Re: Cocoa window messages in app being ported from Carbon (From: Kurt Bigler via Cocoa-dev <email@hidden>)
 >Re: Cocoa window messages in app being ported from Carbon (From: Rob Petrovec via Cocoa-dev <email@hidden>)

  • Prev by Date: Re: Cocoa window messages in app being ported from Carbon
  • Next by Date: Re: Cocoa window messages in app being ported from Carbon
  • Previous by thread: Re: Cocoa window messages in app being ported from Carbon
  • Next by thread: Re: Cocoa window messages in app being ported from Carbon
  • Index(es):
    • Date
    • Thread