> Le 24 janv. 2016 à 09:51, Arved von Brasch <co...@atgo.org> a écrit : > > Hello list, > > After putting it off for too long, I’m migrating to view-based NSTableViews. > I’ve worked through most of the conversion problems I’ve had, and am > generally pretty happy. There is, however, one problem I haven’t been able > to solve. > > I have a NSButton in the same window as my table. The button has “return” as > a key-equavlent. This worked fine with a cell-based NSTableView, but with a > view-based table, ending editing in the table with a “return” key press > always triggers the NSButton as well. This is obviously undesirable > behaviour, but I can’t work out an obvious place to intercept the “return” > key press and discard it. > > My attempts thus far have been messing around with a subclass of the > NSTableView. I’m thinking this is probably wrong, and I should be subclassing > the NSTextField instead, but my experience with such things is minimal, and > my Google-Fu has failed me in finding someone else with a similar problem. > So, my question is if anyone can give me a pointer to how to go about this. > > Thanks in advance, > Arved
You may try too use the TextField delegate methods, especially: - (BOOL)control:(NSControl <file:///Users/jddupas/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.OSX.docset/Contents/Resources/Documents/documentation/Cocoa/Reference/ApplicationKit/Classes/NSControl_Class/index.html#//apple_ref/doc/c_ref/NSControl> *)control textView:(NSTextView <file:///Users/jddupas/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.OSX.docset/Contents/Resources/Documents/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTextView_Class/index.html#//apple_ref/doc/c_ref/NSTextView> *)textView doCommandBySelector:(SEL)command You can detect that this is a return if the selector match @selector(insertNewline:), and in such case, return true to inhibit the event. Return false in all other cases. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com