Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9013919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:23:11+00:00 2026-06-16T03:23:11+00:00

I have a menu item foobar that i need to enable on my main

  • 0

I have a menu item “foobar” that i need to enable on my main window (app delegate), but disable on all other windows. I’d like to know how to do that, because the first responder business is very confusing to me. Here’s what i have now:

  • “foobar” item is connected to first responder’s “foobar:” custom action in MainMenu.xib
  • there is a “foobar:” action in the main app delegate so the menu item is enabled and works
  • now i load and “makeKeyAndOrderFront” another window
  • i focus some control on that new window
  • this is the place where my “foobar” item should be disabled, but it’s not

I can see that the “validateMenuItem” is being called in the app delegate, but it’s not being called in the second window’s controller.

Could someone explain it to me in very simple terms why this is happening and what options i have to solve this?

Thanks for your thoughts

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T03:23:12+00:00Added an answer on June 16, 2026 at 3:23 am

    Set your app delegate as delegate of the main window, and implement these method:

    - (void)windowDidBecomeKey:(NSNotification *)notification
    {
        [foobar setEnabled: YES];
    }
    
    - (void)windowDidResignKey:(NSNotification *)notification
    {
        [foobar setEnabled: NO];
    }
    

    About first responder

    The first responder is a NSControl that is inside the window.For example on a particular window you have two text fields: textField1 and textField2.When you type the input goes just to the first responder (one between all the controls that accept the first responder).So what you need is to know which window is key, you don’t need to know who is the first responder in your specific case.

    EDIT

    There is also another (maybe faster, but depends on personal preferences) way to do it: through interface builder, select the menu item that you want to make enabled only when a certain window is key.Let’s suppose that this window is an ivar of the app delegate named window1.Then click on that menu item, go to the bindings inspector, under “enabled” select bind to: app delegate, model key path: self.window.isKeyWindow.

    A little image hint:

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my app's main menu I have a menu item that I'd like to
I have a main menu window. On clicking any menu item it opens a
I have a nib (winA.xib) that contains a window. My app delegate contains an
I have Menu item List All Categories. Problem, that categories do not count articles
I have a menu item inside the main app menu and I’d like to
I have dropdown menu item (pin this site) that i need to hide it
I have a menu item Home in my main menu AND in my top
I have menu structure as show here . All item have a background img.
I have a menu item that needs to be formated like This & That,
For example I have a menu item named Categories and under that I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.