Bring a window to the front

Discussion in 'Mac Programming' started by prostuff1, Feb 17, 2009.

  1. macrumors 65816

    prostuff1

    Joined:
    Jul 29, 2005
    Location:
    Don't step into the kawoosh...
    #1
    I am modifying the code of Transmission to include a crude menulet. As of now it only displays the upload and download speed, pause all torrents, resume all torrents, toggle the speed limit and bring up some of the Transmission windows.

    The one problem I am having is that if i hide the app or minimize it and then use the menulet to bring up the main Transmission it does not come to the front.

    I have done some basic searching but could not find anything.

    What code would i need to add to make the window come to the front when selecting it from the menulet.
     
  2. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    You probably need to activate the app also. Try this:
    Code:
    [NSApp activateIgnoringOtherApps:YES];
    [window makeKeyAndOrderFront:nil];
     
  3. macrumors regular

    hiddenpremise

    Joined:
    Jul 25, 2008
    Location:
    Somewhere between my imagination and reality
    #3
    Make the controller for your the NIB for your window to be an NSWindowController. Then cntrl drag from that class in interface builder to the window and select "window"

    In your code write
    [self showWindow:self];
    Or from another controller
    [myNibController showWindow:self];
     
  4. thread starter macrumors 65816

    prostuff1

    Joined:
    Jul 29, 2005
    Location:
    Don't step into the kawoosh...
    #4
    Thank you both. This worked the way i wanted it to and it was easy enough to modify the code. I figured it was something simple but could not find the reference for it.
     

Share This Page