NSTableView - 选择行并立即响应鼠标事件 [英] NSTableView - select row and respond to mouse events immediately

查看:2164
本文介绍了NSTableView - 选择行并立即响应鼠标事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于视图的NSTableView,其中的单元格包含一些控件,包括文本字段和编辑字段。当用户尝试点击单元格内的控件以便例如开始编辑文本字段时,忽略点击的主要目标并且选择单元格。

I have a view based NSTableView in which the cells contain a number of controls including text fields and edit fields. When a user tries to click on a control within a cell in order to, for example, start editing a text field, the click's main objective is ignored and the cell gets selected. Another click is then needed to perform the action originally intended, and even this click is subject to a delay before it's taken into account.

我如何避免这个问题,并且有一个

How can I avoid this problem and have the row selected and the mouse event forwarded to the control in one go?

推荐答案

我通过继承NSTableView解决了这个问题:

I solved this issue by subclassing NSTableView:

@implementation QuickResponseTableView

- (BOOL)validateProposedFirstResponder:(NSResponder *)responder forEvent:(NSEvent *)event
{
    // This allows the user to click on controls within a cell withough first having to select the cell row
    return YES;
}

@end

这篇关于NSTableView - 选择行并立即响应鼠标事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆