On Jul 26, 2011, at 7:52 AM, Bill Appleton <billapple...@dreamfactory.com> 
wrote:


> BUT my question is that it seems like there ought to be an easy or automatic 
> way to do this. If i right-click on a text control i get a pop up menu with 
> cut, copy, and other options. That same control isn't smart enough to handle 
> the control-X key? It just seems strange, I'm looking for the right way to do 
> this & don't want to reinvent the wheel for controls in a dialog.

First, it's Command-X, not Control-X.

Secondly, the way that key equivalents work is that they're sent to the menu 
bar first. In this case, the Cut menu item on the Edit menu should claim the 
Cmd-X shortcut, and then begin it's -validateMenuItem: process down the 
responder responder chain. Since you're talking about cutting text, that means 
you're using an NSTextField, right? The NSTextField's field editor responds to 
-cut: so -validateMenuItem: will be called on the field editor. It should 
return YES if the field is editable, which will cause the menu item to send its 
action (-cut:) to the field editor.

No custom implementation of -performKeyEquivalent: is required.

So: what happens if you select some text in your text field and bring up the 
Edit menu? Is the Cut item disabled? Does it have the proper shortcut listed 
next to it?

--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

Reply via email to