Escape in NSTableView cell

2011-02-07 Thread Ivan C Myrvold
I have developed an application with a table view and text edit cell. When I 
press escape from a table view cell, I want the cell to lose focus and end 
editing. Instead I get a list of words in the cell. See picture at 
http://www.myrvold.org/cocoa/images/editcell_escape.png 

How can I avoid the list and get the functionality I 
want?___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Escape in NSTableView cell

2011-02-07 Thread Dave Reed

On Feb 7, 2011, at 9:49 AM, Ivan C Myrvold wrote:

 I have developed an application with a table view and text edit cell. When I 
 press escape from a table view cell, I want the cell to lose focus and end 
 editing. Instead I get a list of words in the cell. See picture at 
 http://www.myrvold.org/cocoa/images/editcell_escape.png 
 
 How can I avoid the list and get the functionality I want?

See this:

http://www.cocoabuilder.com/archive/cocoa/176709-esc-to-cancel-editing-in-tableview.html

Subclassing NSTableView and overriding cancelOperation appears to work. I don't 
know if there's a better way though.

Dave

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Escape in NSTableView cell

2011-02-07 Thread Kyle Sluder
On Mon, Feb 7, 2011 at 8:05 AM, Dave Reed davel...@mac.com wrote:
 See this:

 http://www.cocoabuilder.com/archive/cocoa/176709-esc-to-cancel-editing-in-tableview.html

 Subclassing NSTableView and overriding cancelOperation appears to work. I 
 don't know if there's a better way though.

I'm not a fan of the Escape-to-autocomplete feature, but even aside
from that, dealing with it as a developer is frustrating. -[NSWindow
doCommandBySelector:] is the method responsible for converting
-cancelOperation: into -complete:. Since NSWindow is the only
implementor of -cancelOperation:, by default it's the one that gets
all the Escape key presses. This is why subclassing NSTableView to
implement -cancelOperation: works, but it's a pain in the neck to
implement on every single editable view in your app.

Instead, I've filed rdar://problem/8967168 asking for a new method on
NSResponder: -completeOrCancelOperation:. Rather than have -[NSWindow
doCommandBySelector:] perform trickery, NSTextView could implement
-completeOrCancelOperation: to do the appropriate thing. The
equivalent of the current behavior would have it call [self
doCommandBySelector:@selector(complete:)]. But an even better
implementation would call [self
doCommandBySelector:@selector(cancelOperation:)] if -isFieldEditor
returns YES. That way field editors get the expected behavior (Escape
cancels editing), multiline text views get the expected behavior
(Escape brings up the completion menu), and implementors have a nice
clean place to control the process (override -doCommandBySelector: or
-textView:doCommandBySelector: to handle -completeOrCancelOperation:).

I've duped this bug to http://www.openradar.me/radar?id=1073404 . If
any AppKit folks are reading this, please consider doing this. It
would make our lives as developers of apps with preferences related to
Escape-to-end-editing much easier.

--Kyle Sluder
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com