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 7055687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:46:43+00:00 2026-05-28T03:46:43+00:00

I show my main window by calling [window makeKeyAndOrderFront:self]; [NSApp activateIgnoringOtherApps:YES]; [window setIsVisible:YES]; [window

  • 0

I show my main window by calling

[window makeKeyAndOrderFront:self];
[NSApp activateIgnoringOtherApps:YES];
[window setIsVisible:YES];
[window display];

which works, but doesn’t set the window to the key window right after this calls. I have to wait “some time” until [NSApp keyWindow] returns the actual window.

I’m wondering now, how long does this take and how can I force a window to become the key window immediately?

  • 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-05-28T03:46:44+00:00Added an answer on May 28, 2026 at 3:46 am

    I think there are probably good reasons that makeKeyAndOrderFront isn’t a synchronous call, namely there could be coordination involved with multiple windows and objects that NSApplication need to take care of to make it happen, so forcing window to become key immediately is probably not supported by Cocoa. This however may not be a problem depending on the problem you are trying to solve.

    Now, my guess is that some of your methods depend on the window being key, and at the moment they are not happening properly because the window doesn’t become key immediately. However, you can implement the NSWindowDelegate protocol, set yourself as window delegate, and override - (void)windowDidBecomeKey:(NSNotification *)notification method to find out when the window did become key. This should also be a global notification in case that works better for you.

    For more details, check out apple docs at http://developer.apple.com/library/mac/#documentation/cocoa/reference/NSWindowDelegate_Protocol/Reference/Reference.html

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

Sidebar

Related Questions

This .show and .hide works great in Firefox 3 but not in IE 7.
I want to display some QTextEdits over my main window at arbitrary locations. Below
I want to re-show the main window after closed when click my app icon
I'm using a QMainWindow as a primary window, and call QMainWindow::show() in main.cpp before
I have a file called hellowf.cs class MyFirstApp { static void Main() { System.Windows.Forms.MessageBox.Show(Hello,
I noticed in the main Django introductin they show a feature that maps python
I'm trying to open a dialog window, but every time I try to open
I used webView to show javaScript,one image was included in the javaScrip,but the webView
I want to add QSplashScreen to PyQT4 application. It works fine from Python, but
Consider this Python program which uses PyGtk and Hippo Canvas to display a clickable

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.