• 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
Custom Hit Testing with thousands of NSTextView's & cursorUpdate:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Custom Hit Testing with thousands of NSTextView's & cursorUpdate:


  • Subject: Custom Hit Testing with thousands of NSTextView's & cursorUpdate:
  • From: Eric Gorr <email@hidden>
  • Date: Thu, 26 Feb 2009 16:31:56 -0500

I have a sample application at:

  http://ericgorr.net/cocoadev/label/ThousandsOfNSTextViews.zip

which demonstrates the problem.

Also, this is related to the message and thread:

  http://lists.apple.com/archives/cocoa-dev/2009/Feb/msg01892.html

Since it doesn't seem possible to reliably know how a NSTextField is going to layout it's text, I have experimented with switching to a NSTextView since that comes with a very handy NSLayoutManager.

However, I am experiencing a strange problem related to hit testing.

I have thousands of views inside of a NSScrollView. The first thing I noticed is that when I clicked on one of these views the default hit testing would have to check nearly all of them to determine which view was hit - this took a long time. Since I laid out these views myself, I wrote a custom hit test method that looks at where the click occurred and simply computes which view was hit - this is quite fast.

However, there seems to be something going on with updating the cursor that is causing each and every view to be hit tested and this takes a long time. Try as I might, I cannot seem to work around this.

The problem is easily seen if one scrolls to the bottom and then starts moving the cursor around. You will notice in the debug output that every view is being hit tested. Setting a break point in the hit test method, the stack looks like:

#0	0x00003831 in -[ItemView hitTest:] at ItemView.m:47
#1	0x91be8b36 in -[NSView _nextResponderForEvent:]
#2	0x91be88d8 in forwardMethod
#3	0x91c6cdbe in -[NSView cursorUpdate:]
#4	0x91b5cddd in -[NSWindow sendEvent:]
#5	0x91b5a0de in handleCursorRect
#6	0x91b2995f in -[NSApplication sendEvent:]
#7	0x91a8669f in -[NSApplication run]
#8	0x91a538a4 in NSApplicationMain
#9	0x00002690 in main at main.m:13

I have tried figuring out just which NSView's cursorUpdate: method is being called, but it does not appear to be any that I have easy access to (my Window, Scroller, or ItemsView).


Any thoughts on this?




_______________________________________________

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


  • Prev by Date: Re: Metrics for a NSTextField
  • Next by Date: Why doesn't this work on my device?
  • Previous by thread: Re: custom control's value change isn't being noticed by controller
  • Next by thread: Why doesn't this work on my device?
  • Index(es):
    • Date
    • Thread