• 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: TransformProcessType() still doesn't show menu (Bug ID# 5905139)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TransformProcessType() still doesn't show menu (Bug ID# 5905139)


  • Subject: Re: TransformProcessType() still doesn't show menu (Bug ID# 5905139)
  • From: Anders Norlander <email@hidden>
  • Date: Wed, 25 May 2011 20:13:00 +0200

The following code works for me on 10.6.7. Leaving out any of the calls after TransformProcessType result in the problem you describe.

      ProcessSerialNumber psn;
      pid_t pid = getpid();
      OSStatus err;
      err = GetProcessForPID(pid, &psn);
      err = TransformProcessType(&psn, kProcessTransformToForegroundApplication);
      err = ShowHideProcess(&psn, true);
      [NSMenu setMenuBarVisible:NO];
      SetFrontProcess(&psn);
      [NSMenu setMenuBarVisible:YES];

/Anders

On 2011-05-25, at 19:08 , Jerry Krinock wrote:

> I spent a couple hours last night re-disovering Apple Bug ID #5905139 which was supposedly opened three years ago by Mike Ash [1].  Mike said:
>
> "I set LSUIElement to 1 in my Info.plist and use TransformProcessType() to bump to a foreground application. This
> works except that it fails to show my app's menu bar.  Switching to another program and back to mine makes it show correctly."
>
> He also said that he was doing the switch when the app launched.  Actually, that works OK for me, so maybe that bug has been fixed as of 10.6.7.  However, I have a more challenging requirement.  My app launches as LSUIBackgroundOnly and can show a Status Item (aka menulet).  My Status Item includes a "Show Menu" menu item.  This item targets TransformProcessType().  So you see the transformation may occur hours after launch.  It is only after this delayed transform that I see the problem; the user needs to activate 1-2 other apps and return to mine before my menu shows.  As Mike found, it's worse if the app was spawned by Xcode/gdb.
>
> So I tried all kinds of things last night: -activateIgnoringOtherApps:YES of course, iterating through all of the -[NSApp windows] and sending them each of them a -display, -makeKeyAndOrderFront:YES.  Nada.  I machine-gunned them with loops and delays, and finally broke out NSAppleScript and tried alternately activating my app and the currently active application.  Still no good.
>
> Since users will do this rarely or more likely never, I wouldn't mind programatically cycling through their frontmost, 2nd-frontmost and 3rd-frontmost apps if I knew what they were so I could restore them to their prior order.  But even the shiny new -[NSWorkspace runningApplications] documentation says that "the order of the array is unspecified".  (Arghh! Why?)  System Events gives no more than the one active application either.
>
> But that may not work anyhow.  Can anyone think of any other bricks I could try throwing at this?
>
> Thanks,
>
> Jerry Krinock
>
> [1] http://www.cocoabuilder.com/archive/cocoa/205558-transformprocesstype-fails-to-show-menu-bar.html?q=TransformProcessType#205558_______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: TransformProcessType() still doesn't show menu (Bug ID# 5905139)
      • From: Jerry Krinock <email@hidden>
References: 
 >TransformProcessType() still doesn't show menu (Bug ID# 5905139) (From: Jerry Krinock <email@hidden>)

  • Prev by Date: add crlf to UITextView
  • Next by Date: Re: How to define allowed file extensions in Info.plist?
  • Previous by thread: TransformProcessType() still doesn't show menu (Bug ID# 5905139)
  • Next by thread: Re: TransformProcessType() still doesn't show menu (Bug ID# 5905139)
  • Index(es):
    • Date
    • Thread