title: Cocoa - go to foreground/background programmatically
body: <p>I have an application with LSUIElement set to 1. It has a built-in editor, so I want the application to appear in Cmd+Tab cycle when the editor is open.</p>
  
  <pre><code>    -(void)stepIntoForeground
      {
          if (NSAppKitVersionNumber &lt; NSAppKitVersionNumber10_7) return;
          if (counter == 0) {
              ProcessSerialNumber psn = {0, kCurrentProcess};
              OSStatus osstatus = TransformProcessType(&amp;psn, kProcessTransformToForegroundApplication);
              if (osstatus == 0) {
                  ++counter;
              } else {
                  //...
              }
          }
      }
      -(void)stepIntoBackground
      {
          if (NSAppKitVersionNumber &lt; NSAppKitVersionNumber10_7) return;
          if (counter == 0) return;
  
          if (counter == 1) {
              ProcessSerialNumber psn = {0, kCurrentProcess};
              OSStatus osstatus = TransformProcessType(&amp;psn, kProcessTransformToUIElementApplication);
              if (osstatus == 0) {
                  --counter;
              } else {
                  //..
              }
          }
      }
  </code></pre>
  
  <p>The problems are:</p>
  
  <ul>
  <li>there's also a Dock icon (not a big deal);</li>
  <li>there's also Menu, that is not a big deal too, but they appear not always.</li>
  </ul>
  
  <p>Is there any way to disable menu at all or to make it appear always in foreground? Thanks in advance.</p>