• 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: Jim Majure <email@hidden>
  • Date: Thu, 17 Dec 2009 11:57:51 -0600

Quincey,

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];
}



On Dec 17, 2009, at 11:49 AM, Quincey Morris wrote:

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

I'm having problems enabling the "Edit>Delete" menu item on a custom view. Here's what I have tried:

- I have linked the Delete menu item to the "delete:" selector of the First Responder in IB.
- I have implemented the "(IBAction) delete: (id) sender;" on my custom view.
- I have implemented the "(BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item" on my custom view
- I have confirmed that my view is being set as first responder at runtime (via acceptsFirstResponder, becomeFirstResponder, resignFirstResponder)


The "Delete" menu item never becomes enabled. I can get the "Cut" menu item to enable and activate when tied to the "cut:" selector, but no luck with "Delete". I'm sure that I'm overlooking something very simple, but being a newbie, I can't figure out what.

Surely this is a job for the debugger. Set a breakpoint in 'validateUserInterfaceItem:' and watch what happens. It could be something as simple as testing for '@selector (delete)' instead of '@selector (delete:)', but you should be able to debug this problem in a shorter time than it took you to write your original post. :)



_______________________________________________

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

_______________________________________________

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: Quincey Morris <email@hidden>
    • Re: Enabling menu items...
      • From: Kyle Sluder <email@hidden>
References: 
 >Enabling menu items... (From: Jim Majure <email@hidden>)
 >Re: Enabling menu items... (From: Quincey Morris <email@hidden>)

  • Prev by Date: iCal-like display class (week)?
  • Next by Date: Re: Linking xib's
  • Previous by thread: Re: Enabling menu items...
  • Next by thread: Re: Enabling menu items...
  • Index(es):
    • Date
    • Thread