• 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: Table View and Tool Tips
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Table View and Tool Tips


  • Subject: Re: Table View and Tool Tips
  • From: Ryan Stevens <email@hidden>
  • Date: Thu, 17 Oct 2002 11:15:40 -0700

On Thursday, October 17, 2002, at 05:50 AM, Andreas Mayer wrote:

> Hello.
>
> Did anyone manage to display tool tips for the cells of a table view?
>
> I tried two different approaches, that both failed:
>
> 1. Setting the whole table view as tool tip rect using
> addToolTipRect:owner:userData: and determining the cell in
> view:stringForToolTip:point:userData:.
> That way I'm able to show the correct tool tip. But it won't disappear
> until I move the mouse outside the table view.
>
> 2. Tracking mouse movement with mouseMoved: and setting a new tool tip
> rect for the cell under the mouse using addToolTipRect:owner:userData:
> every time.
> view:stringForToolTip:point:userData: does not get called. I suppose
> this is because the mouse is already inside the rectangle when I
> register it. (Besides, I get an error when trying to removeAllToolTips
> and none are defined. But there seems to be no way to find out
> beforehand.)
>
> I can imagine a third approach:
>
> 3. Setting up tool tips rects for each single cell in the table view
> and recreating all of them when the table view or one table column
> changes size.
> That seems a lot of overhead and will probably not be feasible for
> large lists.
>
> I could manage the tooltips myself with mouseMoved: and timers - if
> there was a way to manually show and hide a tool tip. But I didn't
> find a way to do it. A NSToolTip class would help. Looks like there's
> not even a toolTipColor method.
>
> If I was able to get this working I would be happy to make the
> solution open source ...
>

As a 4th way...

Subclass NSCell.
Add a -view:stringForToolTip:point:userData: method.

Add a way to setup a tooltip, such as;

// what I used for testing...
- (void)resetTooltipForColumn:(int)column andRow:(int)row
inTableview:(NSTableView *)view
{
NSRect aRect;

// if we already have a tooltip for this cell, remove it.
[view removeToolTip:toolTipTag];

// get our rect.
aRect = [view frameOfCellAtColumn:column row:row];

// keep track of our tooltip so we can remove it before creating a
new 1.
toolTipTag = [view addToolTipRect:aRect owner:self userData:NULL];
}

Then, you can use the table view delegate method
-tableView:willDisplayCell:forTableColumn:row:
to convert the cell to a "ToolTipCell" and, basically, away you go.

I know this works. As a challenge to myself, I tried it. It only took a
couple minutes to write - granted, what I got working isn't very good
but that's because I didn't feel like optimizing it or working on more
general use...it "just" works.

I use your #3 method in an app I wrote back in the Public Beta days.
Now, I think I'm going to have to spend a bit more time on this and fix
up my old code.

Thanks for bringing this question to the list. I hope my answer helps
you as much as it has me! ;-)
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Table View and Tool Tips
      • From: Ryan Stevens <email@hidden>
References: 
 >Table View and Tool Tips (From: Andreas Mayer <email@hidden>)

  • Prev by Date: Re: NSSplitView query
  • Next by Date: Re: ___gxx_personality_v0 undefined
  • Previous by thread: Table View and Tool Tips
  • Next by thread: Re: Table View and Tool Tips
  • Index(es):
    • Date
    • Thread