swift - Correct behaviour of Mouse down inside row of NSTableView? -


i have nstableview nsview based. in each row have nsimageview subview of nsview. have subclassed nsimageview overrided mousedown method. problem tableviewselectiondidchange getting fired when user clicks on imageview. want mousedown called not tableviewselectiondidchange.

if set selectionhighlightstyle of table nstableviewselectionhighlightstyle.none mousedown of image view called. , if don't give selectionhighlightstyle nstableviewselectionhighlightstyle.none both mousedown of imageview , tableviewselectiondidchange getting called. setting selectionhighlightstyle none seems solve problem correct approch? or getting behaviour because of bug in appkit?

also can't find behaviour documented somewhere.

i think correct approach subclass nstableview , override nsresponder method -(bool)validateproposedfirstresponder:(nsresponder *)responder forevent:(nsevent *)event

you'll have finer control on view mouse event, , won't have resort "hackery" changing table view selection style.

from apple docs:

specifying how subviews should respond events

views or controls in table need respond incoming events. determine whether particular subview should receive current mouse event, table view calls validateproposedfirstresponder:forevent: in implementation of hittest. if create table view subclass, can override validateproposedfirstresponder:forevent: specify views can become first responder. in way, receive mouse events.

the default nstableview implementation of validateproposedfirstresponder:forevent: uses following logic:

return yes proposed first responder views unless instances or subclasses of nscontrol. determine whether proposed first responder nscontrol instance or subclass.

if control nsbutton object, return yes.

if control not nsbutton, call control’s hittestforevent:inrect:ofview: see whether hit area trackable (that is, nscellhittrackablearea) or editable text area (that is, nscellhiteditabletextarea), , return appropriate value. note if text area hit, nstableview delays first responder action.

https://developer.apple.com/library/mac/documentation/cocoa/conceptual/tableview/rowselection/rowselection.html#//apple_ref/doc/uid/10000026i-ch6-sw9


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -