• 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: [Q] Cocoa newbie question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Q] Cocoa newbie question


  • Subject: Re: [Q] Cocoa newbie question
  • From: James Chen <email@hidden>
  • Date: Thu, 11 Dec 2003 11:02:38 +0800

On Dec 11, 2003, at 10:17 AM, Sherm Pendley wrote:

On Dec 10, 2003, at 8:50 PM, Steve Christensen wrote:

I've been playing around writing some small apps to try stuff out. I did a custom about box (i.e., call my own code instead of calling -orderFrontStandardAboutPanel) and noticed that the Print item was enabled

etc.? Or is there a "better practices" way of doing it that I haven't yet figured out?

Implement the NSMenuValidation protocol in your controller object - that is, implement the validateMenuItem: method.

sherm--
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

Hi,
Here's another solution.
Default target and action of menu item "Print" in nib file are "First Responder" and "print:" respectively.
The menu item "Print" will be always enabled since NSView implement message/method "print:".
If you change the action of "Print" to "printDocument:" in "First Responder", the "Print" will be always disabled except
one of the instance implements "printDocument:" in the responder chain. (only NSDocument implements this action by default)

So you may implement "printDocument:" in your window's delegate to enable "Print" only if this window is printable in your aspect of view.
Further more, you may implement "validateMenuItem:" to determine the state of "Print" dynamically.

For precise information please visit
http://developer.apple.com/documentation/Cocoa/Conceptual/MenuList/ index.html?http://developer.apple.com/documentation/Cocoa/Conceptual/ MenuList/Tasks/EnablingMenuItems.html

Hope this will help,
James
------------------------------------
Ulead Systems Inc.
James Chen
Software Engineer
Image Div.
------------------------------------
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: [Q] Cocoa newbie question
      • From: Steve Christensen <email@hidden>
References: 
 >[Q] Cocoa newbie question (From: Steve Christensen <email@hidden>)
 >Re: [Q] Cocoa newbie question (From: Sherm Pendley <email@hidden>)

  • Prev by Date: Re: [Q] Cocoa newbie question
  • Next by Date: Re: reading XML in Cocoa ?
  • Previous by thread: Re: [Q] Cocoa newbie question
  • Next by thread: Re: [Q] Cocoa newbie question
  • Index(es):
    • Date
    • Thread