Re: View-based NSTableView and ending editing with "return"

2016-02-03 Thread Jean-Daniel Dupas

> Le 24 janv. 2016 à 09:51, Arved von Brasch  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 

 *)control textView:(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

View-based NSTableView and ending editing with "return"

2016-01-24 Thread Arved von Brasch
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
___

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