• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Enabling menu items...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Enabling menu items...


  • Subject: Re: Enabling menu items...
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 17 Dec 2009 10:27:18 -0800
  • Resent-date: Thu, 17 Dec 2009 10:45:08 -0800
  • Resent-from: Quincey Morris <email@hidden>
  • Resent-message-id: <email@hidden>
  • Resent-to: cocoa-dev <email@hidden>

[Reposted to list after being misdirected. Slightly edited from the original.]

On Dec 17, 2009, at 09:57, Jim Majure wrote:

> I wish that were the case. However, the validateUserInterfaceItem: message isn't being invoked for "delete:"
>
> Here's the relevant code.
>
> - (BOOL) acceptsFirstResponder {
> 	NSLog(@"acceptsFirstResponder");
> 	return YES;
> }
> - (IBAction) delete:(id) sender {
> 	NSLog(@"delete invoked");
> }
>
> - (BOOL) becomeFirstResponder {
> 	NSLog(@"becomeFirstResponder");
> 	return YES;
> }
>
> - (BOOL) resignFirstResponder {
> 	NSLog(@"resignFirstResponder");
> 	return YES;
> }
>
> - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem {
> 	NSLog(@"validateUserInterfaceItem");
>     SEL theAction = [anItem action];
>
>     if (theAction == @selector(delete:)) {
> 		return YES;
>     } else if (theAction == @selector(cut:)) {
> 		if (selectedCell && [selectedCell selected]) {
> 			return YES;
> 		}
> 		return NO;
> 	}
> 	return NO;
> }
> - (IBAction) cut: (id) sender {
> 	NSLog(@"cut");
> 	[timeEntryController deleteSelectedEntry];
> }

So, one of two things happened:

1. Your view really isn't first responder, and another responder is handling 'delete:'.

2. Something is modifying the target/action configuration of the menu item so that 'delete:' is being sent to a different responder, not First Responder, or a different action is being sent.

It's also possible that your view is a subview of something that implements a check for 'delete:' in 'validateMenuItem:' instead of 'validateUserInterfaceItem:', and that's sucking up the action.

You could try (temporarily) renaming your menu item's action and your method to 'myDelete:' or something and see if that works. If so, the responder chain is fine, and your problem is just that something else is getting hold of 'delete:' first.


_______________________________________________

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

  • Follow-Ups:
    • Re: Enabling menu items...
      • From: Jim Majure <email@hidden>
References: 
 >Enabling menu items... (From: Jim Majure <email@hidden>)
 >Re: Enabling menu items... (From: Quincey Morris <email@hidden>)
 >Re: Enabling menu items... (From: Jim Majure <email@hidden>)

  • Prev by Date: Re: iCal-like display class (week)?
  • Next by Date: Re: Overriding NSArrayController to be used in a many-to-many RS and NSTable Bindings
  • Previous by thread: Re: Enabling menu items...
  • Next by thread: Re: Enabling menu items...
  • Index(es):
    • Date
    • Thread