鼠标悬停在NSTableView中 [英] Mouseover in NSTableView
问题描述
我无法使用NSTableView创建鼠标悬停功能。想法是(如果在prefs中选择特征)将鼠标指针放在NSTabelView中的特定行上面将显示一个小的弹出窗口,其中包含关于该特定行中的条目的附加信息。效果不应该是立即的(例如,当滚动它的时候按下一个按钮),但是延迟几秒钟。
到目前为止,我已经实现了功能使用工具提示委托方法,但是这不允许自定义的窗口,并且不能很好地(布局明智)如果需要显示超过1-3行的信息。
在Hillegass的书中,建议使用mouseEntered / mouseExited方法进行翻转,但是我可以告诉这对于窗口的预定义区域,而不是表视图中的行。 p>
有人有任何建议吗?
Gregor Tomasevic,
瑞典
使用-mouseEntered:和-mouseExited:。
NSView的-addTrackingRect:owner:userData:assumeInside:和-removeTrackingRect:方法。你可以设置tableView来为tableView的内容创建trackingRects,每当tableView的内容改变时,或者在整个tableView上设置/更新一个跟踪区域,只要调用了tiles或另一个布局相关的方法。 / p>
I'm having trouble creating a mouseover function with an NSTableView. The idea is that (if the feature is selected in prefs) placing the mouse pointer above a particular row in an NSTabelView will display a small popup window with additional information regarding the entry in that particular row. The effect should not be immediate (as e.g. highliting a button when rolling over it), but come with a delay of a few seconds.
So far, I have implemented this functionality using the tooltip delegate method, but this does not allow for customization of the window and does not work well (layout wise) if more than 1-3 rows of info need to be displayed.
In Hillegass' book it is suggested that one uses the mouseEntered/mouseExited methods for rollovers, but as far as I can tell this works with pre-defined areas of a window and not rows in a table view.
Does anyone have any suggestions?
Gregor Tomasevic, Sweden
You're on the right track with -mouseEntered: and -mouseExited:.
Look into NSView's -addTrackingRect:owner:userData:assumeInside: and -removeTrackingRect: methods. You can either set up your tableView to create trackingRects for every row that's in there whenever the contents of the tableView change, or alternatively, set up/update one tracking area on the entire tableView whenever -tile or another layout related method is called.
这篇关于鼠标悬停在NSTableView中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!