On Nov 20, 2008, at 4:01 AM, Quincey Morris wrote:
On Nov 19, 2008, at 18:34, Mudi Dandan wrote:

I'm using automatic menu validation.
The problem comes from that I exchange close window/close tab (as in Safari) shortcuts during the validation process. Unfortunately -validateUserInterfaceItem: doesn't seem to be called when pressing a shortcut, so hitting command-w will close the window instead of the current tab. Using the mouse it would work fine.

Aside from the issue of whether this is a good thing to do, I think it's not going to work because you're making an assumption that isn't true.

Switching a key equivalent at validation time could only work if all menu items were validated *before* the menu item corresponding to the key equivalent is found. I just tried this, and AFAICT it finds the menu item *first* and validates just that item. That means you're pretty much out luck, as far as doing it at validation time.

This behavior contradicts the documentation:

http://developer.apple.com/documentation/Cocoa/Conceptual/MenuList/Articles/EnablingMenuItems.html#/ /apple_ref/doc/uid/20000261-74653-BAJBGJHB

"When you use automatic menu enabling, NSMenu updates the status of every menu item whenever a user event occurs."

I think we already knew that it didn't happen literally every event, but the part about "every menu item" also appears to be false in the key equivalent case.


It works with a little trick that whichever is being validated (closetab: or closewindow:) I reassign the shortcuts for both items, and shortcuts has to be restored in windowDidResignKey: so that ordinary windows can be closed with command-w.

_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to