Re: TableView Mouse Tracking problem
Re: TableView Mouse Tracking problem
- Subject: Re: TableView Mouse Tracking problem
- From: Matt Ball <email@hidden>
- Date: Tue, 12 Jul 2005 22:15:59 -0400
Good call. It didn't work initially, but after some modifications,
it's working. Here's the final code in case anyone else if looking to
implement something like this:
- (void)setMouseHoverOnRow:(int)row column:(int)column {
mouseOverRow = row;
mouseOverColumn = column;
NSRect coreImageColumnRect = [layersView rectOfColumn:2];
NSRect lockedColumnRect = [layersView rectOfColumn:3];
// Reset all buttons to the unhovered state
NSTableColumn *coreImageCol = [[layersView tableColumns]
objectAtIndex:2];
[[coreImageCol dataCell] setMouseOver:NO];
NSTableColumn *lockCol = [[layersView tableColumns] objectAtIndex:3];
[[lockCol dataCell] setMouseOver:NO];
if(mouseOverColumn == 2 || mouseOverColumn == 3)
mouseHoveredOnButton = YES;
[layersView setNeedsDisplayInRect:coreImageColumnRect];
[layersView setNeedsDisplayInRect:lockedColumnRect];
}
- (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell
forTableColumn:(NSTableColumn *)tableColumn row:(int)row
{
if(mouseOverColumn == 2 || mouseOverColumn == 3) {
int col;
if(tableColumn == [[layersView tableColumns] objectAtIndex:2])
col = 2;
else if(tableColumn == [[layersView tableColumns]
objectAtIndex:3])
col = 3;
else
col = nil;
BOOL hovered = (row == mouseOverRow && col == mouseOverColumn);
[cell setMouseOver:hovered];
}
}
Thanks for your help.
- Matt Ball
On 7/12/05, Corbin Dunn <email@hidden> wrote:
> Did you change your code to use the latter technique?
>
> --corbin
>
> On Jul 12, 2005, at 6:34 PM, Matt Ball wrote:
>
> > Thanks for the input, but that code didn't have any effect :/
> >
> > - Matt Ball
> >
> > On 7/12/05, Corbin Dunn <email@hidden> wrote:
> >
> >> Matt,
> >>
> >>>
> >>> - (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell
> >>> forTableColumn:(NSTableColumn *)tableColumn row:(int)row
> >>> {
> >>> if(mouseHoveredOnButton) {
> >>> [cell setMouseOver:YES];
> >>> mouseHoveredOnButton = NO;
> >>> }
> >>> }
> >>>
> >>>
> >>
> >> The same cell is shared for one column. You may want to have it read
> >> something like:
> >>
> >>
> >>> if(mouseHoveredOnButton) {
> >>> [cell setMouseOver:YES];
> >>> mouseHoveredOnButton = NO;
> >>> }
> >>>
> >>>
> >>
> >> else { [cell setMouseHover:NO; }.
> >>
> >>
> >> In addition, you may want to store what row/col you are hovering
> >> over, and perform that check instead:
> >>
> >> BOOL hovered = (row == hoverRow && col == hoverCol);
> >> [cell setHovered:hovered];
> >>
> >> --=corbin
> >>
> >
>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden