Re: Escape in NSTableView cell
Re: Escape in NSTableView cell
- Subject: Re: Escape in NSTableView cell
- From: Kyle Sluder <email@hidden>
- Date: Mon, 7 Feb 2011 12:29:22 -0800
On Mon, Feb 7, 2011 at 8:05 AM, Dave Reed <email@hidden> 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 (email@hidden)
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:
This email sent to email@hidden