NSTrackingArea, Pie charts and not rectangular areas

  • Hello,

    I've currently got several classes that implement a pie chart for the
    application I'm working on.  The pie chart appears in a subview of a
    window and this subview has an NSTrackingArea.  The pie chart itself
    is drawn using NSBezierPath, where each section of the pie chart is
    its own path.  As each section is drawn you end up building the pie
    chart.  Also, as each path is created I add it to a dictionary as a
    key and make the associated value a string that will be the tooltip
    for that section.

    Then, in mouseMoved I iterate over the dictionary keys and if the key
    (an NSBezierPath) returns YES for containsPoint I set the toolTip.
    The main problem with this implementation appears to be that the
    tooltip won't change unless I leave the subview and reenter it.  I've
    tried removeAllToolTips to fix this problem, but it didn't help.

    Does anyone have suggestions on a better implementation?  I'd love to
    have a tracking area setup for each pie chart section, but this
    doesn't seem to be possible since the sections are not rectangular.

    Thanks,

    Adhamh
  • Did you remember to enable mouseMoved events?  By default AppKit
    doesn't send them because they are so numerous; you have to explicitly
    ask for them.

    --Kyle Sluder
  • On Jan 15, 2008, at 3:46 PM, Kyle Sluder wrote:

    > Did you remember to enable mouseMoved events?  By default AppKit
    > doesn't send them because they are so numerous; you have to explicitly
    > ask for them.
    >
    > --Kyle Sluder

    I don't think you have to enable mouse events when using an
    NSTrackingArea.  At least, right now I don't have mouse events enabled
    on the window in question, but mouseMoved does fire appropriately.  As
    a test I did enable mouse events and the problem did change, so it
    appears that tracking areas don't require setAcceptsMousedMovedEvents.

    The problem I am having is that the toolTips don't update properly, as
    long as I'm inside the tracking area the toolTip won't dimiss.  I'm
    also wondering if my implementation could be better...

    Adhamh
  • On Jan 15, 2008 6:21 PM, Adhamh Findlay <cocoadev...> wrote:
    > I don't think you have to enable mouse events when using an
    > NSTrackingArea.  At least, right now I don't have mouse events enabled
    > on the window in question, but mouseMoved does fire appropriately.  As
    > a test I did enable mouse events and the problem did change, so it
    > appears that tracking areas don't require setAcceptsMousedMovedEvents.

    Ah, okay, I didn't make the connection.  Perhaps the standard tooltip
    functionality isn't for you, then?

    --Kyle Sluder
previous month january 2008 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today