How to hide my app with Obj-C code

Discussion in 'Mac Programming' started by Oats, Feb 5, 2011.

  1. Oats macrumors regular

    Joined:
    Jan 8, 2003
    Location:
    New York
    #1
    I've got a utility app I'm developing for OS X (hopefully targeting 10.5 and up). My window floats above other windows, and occasionally I want to hide the my app/window and let users continue running whatever program was behind it. Similar to if the user pressed "cmd-H" to hide my app.

    The problem is, I don't know how to do this programmatically with cocoa. I can hide my window, but my app's menubar is still frontmost. Things I have tried that did not work:

    Code:
    [NSApp hide:self];
    [NSApp deactivate];
    Please help, thanks!
     
  2. Oats thread starter macrumors regular

    Joined:
    Jan 8, 2003
    Location:
    New York
    #2
    In formulating the question for this post, I finally was able to choose the right google keywords to lead me to a solution. This seems to work:
    Code:
    	ProcessSerialNumber psn;
    	GetFrontProcess (&psn);
    	ShowHideProcess (&psn,false);
     
  3. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #3
    I find it hard to believe [NSApp hide:nil] didn't work.
     

Share This Page