• 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: NSStatusItem popUpStatusItemMenu shows menu over main menubar instead of below it
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: NSStatusItem popUpStatusItemMenu shows menu over main menubar instead of below it


  • Subject: RE: NSStatusItem popUpStatusItemMenu shows menu over main menubar instead of below it
  • From: Dan Stenning <email@hidden>
  • Date: Tue, 09 Jun 2015 18:58:51 +0100
  • Importance: Normal

thanks - i seem to recall i tried calling it on NSStatusitem itself but made no difference. 

I’ll join the Cocoa dev group as you suggest though. 


Subject: Re: NSStatusItem popUpStatusItemMenu shows menu over main menubar instead of below it
From: email@hidden
Date: Mon, 8 Jun 2015 22:00:28 -0500
CC: email@hidden
To: email@hidden

This would have been a better fit for the cocoa-dev mailing list, since this has nothing to with the Xcode IDE itself.

You are setting the menu on some view (whatever pimpl->getView() returns) rather than the NSStatusItem itself.  Set the menu property of the NSStatusItem rather than some view.  When it's on the view, it is a contextual menu for that view, which is presumably why it shows up on top of it.

Regards,
Ken

On Jun 8, 2015, at 9:23 PM, Dan Stenning <email@hidden> wrote:

I have this cocoa code in order to show a menu when a “menu app” or menu-extras icon is clicked on
on the menu bar.  

Only trouble is it pops up on top of my menu-app icon, at the very top  instead of right _below_ the menu bar. What am i doing wrong ? 

here is the code in question: 


  // NOTE:  pimpl->statusItem is a  NSStatusItem* 


void SystemTrayIconComponent::createMenu()

{

    

    NSMenuItem *tItem = nil;

    

    pimpl->theMenu = [[NSMenu alloc] initWithTitle:@""];

    [pimpl->theMenu setAutoenablesItems:NO];

    
    

    [pimpl->theMenu addItemWithTitle:@"One" action:nil keyEquivalent:@""];

    [pimpl->theMenu addItemWithTitle:@"Two" action:nil keyEquivalent:@""];

    [pimpl->theMenu addItemWithTitle:@"Three" action:nil keyEquivalent:@""];

    

    [pimpl->theMenu addItem:[NSMenuItem separatorItem]];

    

    tItem = [pimpl->theMenu addItemWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"];

    [tItem setKeyEquivalentModifierMask:NSCommandKeyMask];

    

    NSStatusBar *statusBar = [NSStatusBar systemStatusBar];

    pimpl->statusItem = [statusBar statusItemWithLength:NSVariableStatusItemLength];

   // [pimpl->statusItem retain];

 

    [pimpl->statusItem setToolTip:@"This is our tool tip text"];

    [pimpl->statusItem setHighlightMode:YES];

    [pimpl->getView() setMenu:pimpl->theMenu];

    

}



void SystemTrayIconComponent::showDropdownMenu(Point<int> mousePos)


    

    [pimpl->statusItem popUpStatusItemMenu: pimpl->theMenu ];


}


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >NSStatusItem popUpStatusItemMenu shows menu over main menubar instead of below it (From: Dan Stenning <email@hidden>)
 >Re: NSStatusItem popUpStatusItemMenu shows menu over main menubar instead of below it (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Refactoring a #define definition
  • Next by Date: Is the f***ing NDA back, or why is no one talking about new stuff?
  • Previous by thread: Re: NSStatusItem popUpStatusItemMenu shows menu over main menubar instead of below it
  • Next by thread: Is the f***ing NDA back, or why is no one talking about new stuff?
  • Index(es):
    • Date
    • Thread