• 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
Invalid window error for a status bar item popup
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Invalid window error for a status bar item popup


  • Subject: Invalid window error for a status bar item popup
  • From: Jeffrey Mattox <email@hidden>
  • Date: Tue, 18 Feb 2003 14:34:23 -0600

I have a status menu item that, when clicked, shows a popup menu via:

theWindow = [[NSWindow alloc] initWithContentRect:contentRect
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreNonretained defer:NO];

theView = [theWindow contentView];

NSEvent* theEvent = [NSEvent mouseEventWithType:NSLeftMouseUp
location:mouseLocation
modifierFlags:0
timestamp:[NSDate timeIntervalSinceReferenceDate]
windowNumber:[theWindow windowNumber] // <-- trouble??
context:[NSGraphicsContext currentContext]
eventNumber:1
clickCount:1
pressure:1.0];

[NSMenu popUpContextMenu:theStatusMenu withEvent:theEvent forView:theView];

However, even though the popup shows up correctly and works fine, I get this error on the Console when the menu is displayed:

kCGErrorIllegalArgument :
CGSSetWindowToReleaseBackingOnOrderOut: Invalid window

I don't intend the empty window to be displayed or brought to the front because the popup is not associated with a window -- it appears under the status bar on top of whatever else happens to be on the screen.

I've tried adding [NSApp preventWindowOrdering] before displaying the popup, but no change.

I've also tried this function which is referred to in the documentation but apparently no longer exists in AppKit/NSGraphics.h:

NSConvertWindowNumberToGlobal([theWindow windowNumber], &globalNum);

There's something wrong with the window number or the graphics context, but I'm getting out of my league here. Perhaps I need to set a value somewhere, but I don't know where. I'm hoping somebody out there will recognize this as a common problem with a simple solution. I worry about just ignoring the error message.

Any ideas?

Jeff
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Invalid window error for a status bar item popup
      • From: Andreas Mayer <email@hidden>
  • Prev by Date: drawing into NSBitmapImageRep
  • Next by Date: Re: AddressBook searching broken in 10.2.4
  • Previous by thread: Re: drawing into NSBitmapImageRep [SOLVED]
  • Next by thread: Re: Invalid window error for a status bar item popup
  • Index(es):
    • Date
    • Thread