美文网首页
NSTableViewCell 添加鼠标事件

NSTableViewCell 添加鼠标事件

作者: 大漠赏花 | 来源:发表于2018-01-23 17:16 被阅读0次

    - (void)awakeFromNib

    {

        CGRectrect =self.bounds;

        rect.size.height=30; // cell 的高度为30,加载进来的时候self.bounds.size.height 为53,暂时不清楚这个值怎么来的(可能原因是headerView高度23加上cell高度30)。所以单独处理下范围高度。

        NSTrackingArea *area =[[NSTrackingArea alloc] initWithRect:rect options:NSTrackingMouseEnteredAndExited|NSTrackingActiveInKeyWindow owner:self userInfo:nil];

        [self addTrackingArea:area];

    }

    - (void)mouseEntered:(NSEvent*)theEvent{

        // 鼠标进入cell范围

    }

    - (void)mouseExited:(NSEvent*)event

    {

       // 鼠标移出cell范围

    }

    相关文章

      网友评论

          本文标题:NSTableViewCell 添加鼠标事件

          本文链接:https://www.haomeiwen.com/subject/oqgsaxtx.html