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

The Archive Base Latest Questions

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

In MAC OS X 10.7, Apple introduced a new class called NSPopover and you

  • 0

In MAC OS X 10.7, Apple introduced a new class called NSPopover and you can even drag away that popover view to become an independent NSWindow. However, I want to prevent user interaction to the main window until the detached window is closed. How can I safely do this?

Actually, a more common (and even more stupid) question should be, how to prevent any user interaction until current front window returns? I am noob to tread programming also.

  • 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:55:50+00:00Added an answer on May 28, 2026 at 3:55 am

    I kind of found the solution myself. It looks working fine now.

    To do this, after the detached window ordered to front and become key window, the following code will make it a modal window (where currModalSession is an iVar defined by myself).

    - (void)windowDidBecomeKey:(NSNotification *)notification {
        if (notification.object == detachedWindow) {
            if (!detachedWindow.isModalPanel) {
                currModalSession = [NSApp beginModalSessionForWindow:detachedWindow];
                [NSApp runModalSession:currModalSession];
            }
        }
    }
    

    Also, you have to end each Modal Session you have opened. So the following code does the job:

    - (void)windowWillClose:(NSNotification *)notification {
        if (notification.object == detachedWindow) {
            if (currModalSession) {
                [NSApp endModalSession:currModalSession];
            }
        }
    }
    

    Note: you have to use Modal Session here rather than runModalForWindow for two reasons:

    1. otherwise the main window won’t be blocked right away. I don’t quite get the reason yet. One possible explanation is: runModalForWindow will not just block user interactions but also internal communications, so main window might need more time to be ready.
    2. if you plan to run another framework modal dialog (e.g. NSOpenPanel) from the detached window, when return, the detached window will become key window before the new modal dialog close, namely runModalForWindow will freeze another to be closed window. That means to be closed window won’t be closed.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Apple's guidelines for their new Mac App Store say that you cannot use deprecated
Is there anytool lik dtruss which can run on linux (ubuntu)? http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/dtruss.1m.html Thank you.
I have a HashMap as follows: Map<String, String> myMap = new HashMap<String,String>(); myMap.put(apple,mac); JSONArray
The html is: <div class=choose-os> <p> <a href=someLink class=windows>Microsoft Windows</a> <a href=someOtherLink class=macos>Apple Mac
Does Apple accept Python applications for distribution on the new Mac App Store? If
Apple suggests that prior to submitting to the Mac application store, the installation process
With Mac OS X 10.7 Apple has introduced AVFoundation and I'm trying to generate
With Xcode 4 on OS X 10.7, Lion, Apple introduced a fantastic new way
Does Apple allow iOS and Mac apps to use Javascript? Can someone give me
Does the apple provide any framework or library for Mac desktop that let me

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.