• 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: NSTableView tooltips
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView tooltips


  • Subject: Re: NSTableView tooltips
  • From: MT <email@hidden>
  • Date: Sun, 28 Mar 2004 17:25:01 +0100

Hi,

Thanks to everyone for replying, all the suggestions seem to do the job, however, I'm using Cocoa/Java, I thought the ObjC method of doing it would apply to Java, but it doesn't look like it does, as the Obj-C way of doing it rely on NSToolTipOwner, which doesn't exist in Java, anyone know a workaround?

Cheers

Moray

Hi Moray,

I'm sure I've seen this somewhere, but I can't find it, so sorry if
this is FAQ. What I want is the tooltips for an NSTableView to be
specific to a cell, preferably controlled by the DataSource. I'm sure
I've seen an example for it, so if somebody could point it out, that
would be great.

Here is the subset of my custom NSTableView, which deals with tooltips:

@interface MyTableView : NSTableView {

BOOL delegateImplementsShouldDisplayToolTips;
BOOL delegateImplementsToolTip;
}

@end


@interface NSObject(MyTableViewDelegate)
- (BOOL)tableViewShouldDisplayCellToolTips:(NSTableView *)tableView;
- (NSString *)tableView:(NSTableView *)tableView
toolTipForTableColumn:(NSTableColumn *)tableColumn row:(int)rowIndex;
@end


@implementation MyTableView

- (void)setDelegate:(id)delegate
{
if (delegate != [self delegate]) {

[super setDelegate:delegate];

delegateImplementsShouldDisplayToolTips = ((delegate &&
[delegate
respondsToSelector:@selector(tableViewShouldDisplayCellToolTips:)]) ? YES :
NO);
delegateImplementsToolTip = ((delegate &&
[delegate
respondsToSelector:@selector(tableView:toolTipForTableColumn:row:)]) ? YES :
NO);
}
}

- (void)reloadData
{
[super reloadData];
[self resetCursorRects];
}

- (void)resetCursorRects
{
[self removeAllToolTips];

if (delegateImplementsShouldDisplayToolTips && [[self delegate]
tableViewShouldDisplayCellToolTips:self]) {

NSRect visibleRect = [self visibleRect];
NSRange colRange = [self columnsInRect:visibleRect];
NSRange rowRange = [self rowsInRect:visibleRect];
NSRect frameOfCell;

for (unsigned col = colRange.location; col < colRange.location +
colRange.length; col++) {

for (unsigned row = rowRange.location; row < rowRange.location +
rowRange.length; row++) {

frameOfCell = [self frameOfCellAtColumn:col row:row];
[self addToolTipRect:frameOfCell owner:self userData:NULL];
}
}
}
}

- (NSString *)view:(NSView *)view stringForToolTip:(NSToolTipTag)tag
point:(NSPoint)point userData:(void *)matrix
{
int rowIndex = [self rowAtPoint:point];
int columnIndex = [self columnAtPoint:point];
NSTableColumn *tableColumn = (columnIndex != -1) ? [[self
tableColumns] objectAtIndex:columnIndex] : nil;

return (columnIndex != -1) ? [[self delegate] tableView:self
toolTipForTableColumn:tableColumn row:rowIndex] : @"";
}

@end

Hope it will gives you nice start...

Eric
___________________________________________________________________

Eric Forget Cafederic
email@hidden <http://www.cafederic.com/>

Fingerprint <86D5 38F5 E1FD 5D9C 71C3 BAA3 797E 70A4 6210 C684>
_______________________________________________
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.
_______________________________________________
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.


References: 
 >Re: NSTableView tooltips (From: Eric Forget <email@hidden>)

  • Prev by Date: AddTrackingRect does not work with two views
  • Next by Date: SIGIO and AppKit main loop
  • Previous by thread: Re: NSTableView tooltips
  • Next by thread: Detecting a paste operation in NSTextView
  • Index(es):
    • Date
    • Thread