• 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: How disable File/Open command -- SOLVED
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How disable File/Open command -- SOLVED


  • Subject: Re: How disable File/Open command -- SOLVED
  • From: Mike Abdullah <email@hidden>
  • Date: Mon, 15 Aug 2011 15:13:48 +0100

On 15 Aug 2011, at 14:52, McLaughlin, Michael P. wrote:

> I managed to find this solution shortly after sending a request to this list for help.  I show the code below so that future programmers might find this more easily that I did.  This solution has not been tested with Lion.  [Note: This app does not have a File/New command and does not open an untitled document.]
>
> ________________________________
> 1. Subclass NSDocumentController --> myDocController

Cocoa class names should generally begin with an uppercase character

> 2. Add the code below to myDocController

You didn't call super, which I'd highly advise. Then apply your custom logic only if the selector is openDocument: and super returned YES.

> 3. Connect File/Open menu command to myDocController's openDocument IBAction (in IB or Xcode 4).

There should be no need for this step. By default the action is sent to the First Responder, which means it'll wind up at the document controller eventually.
>
>
> - (IBAction)openDocument:(id)sender
>
> {
>
>   [super openDocument:sender];
>
> }
>
>
> -(BOOL)validateMenuItem:(id)sender
>
> {
>
>   BOOL ok = YES;
>
>   extern BOOL haveData;
>
>
>   if ([sender action] == @selector(openDocument:))
>
>      ok = (haveData == NO);
>
>
>
>   return ok;
>
> }
>
> --
> Mike McLaughlin
> _______________________________________________
>
> 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

References: 
 >How disable File/Open command -- SOLVED (From: "McLaughlin, Michael P." <email@hidden>)

  • Prev by Date: Re: How does Apple want us to deal with custom elements in Xcode 4, with IBPlugins having been killed?
  • Next by Date: Re: recomendations for creating a beta with date to expire
  • Previous by thread: How disable File/Open command -- SOLVED
  • Next by thread: compiling app for 10.6 and 10.7
  • Index(es):
    • Date
    • Thread