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

  • Home
  • SEARCH
  • 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 4273178
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:40:39+00:00 2026-05-21T07:40:39+00:00

I am working on a dockless application ( LSUIElement true). The application pops up

  • 0

I am working on a dockless application (LSUIElement true). The application pops up a menu when the user clicks on the corresponding NSStatusItem, or when a keyboard shortcut is used.

My problem is that all methods to pop up a menu programmatically hang whenever the user switches to another application (using ⌘-TAB) without dismissing the menu first. I have tried popUpMenuPositioningItem:atLocation:inView:, popUpContextMenu:withEvent:forView:, and the corresponding method on NSStatusItem (popUpStatusItemMenu:).

If the user dismisses the menu with the ESC key everything works fine, but if the user switches to a different application, the above-mentioned methods never return (they seem to run synchronously and return when the menu is dismissed). The application does not crash, and there are a couple of tricks to regain control (invoking exposé, or clicking on any NSStatusItem which pops up a menu).

The problem disappears if the application has a dock icon (i.e. setting LSUIElement to false).

This is the code popping up the menu when the keyboard shortcut is used:

[mainMenu popUpMenuPositioningItem:[mainMenu itemAtIndex:0]
                        atLocation:[NSEvent mouseLocation]
                            inView:nil];

And this is the code popping up the menu when the NSStatusItem is clicked:

- (void)mouseDown:(NSEvent *)event
{
    [statusItem popUpStatusItemMenu:[statusItem menu]];
}

The mouseDown: method is in the custom NSView attached to the NSStatusItem.

Any idea on how to fix this?

Thanks for your help.

Update

The problem is also linked to the application being activated (I use [NSApp activateIgnoringOtherApps:YES]; before showing the menu, or in some cases it is not possible to navigate the menu with the keyboard).

  • 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-21T07:40:40+00:00Added an answer on May 21, 2026 at 7:40 am

    It appears that the problem is due to the application activation and popUpMenu happening in the same event cycle. I have found a workaround, described in more details in this post.

    Is summary, you need to activate the application first (using [NSApp activateIgnoringOtherApps:YES];), and pop up the menu after, making sure this happens in a new event cycle: you can achieve this using a NSTimer to trigger the menu.

    - (void) someMethod {
        // Some code
        [NSApp activateIgnoringOtherApps:YES];
        [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(showMenu) userInfo:nil repeats:NO];
        //Some other code
    }
    
    - (void) showMenu {
        // This will show the menu at the current mouse position
        [aMenu popUpMenuPositioningItem:[mainMenu itemAtIndex:0] atLocation:[NSEvent mouseLocation] inView:nil];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a project in C# w/ XNA, and I want to reorganize
I have a script that appends some rows to a table. One of the

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.