views:

18

answers:

2

This is a rather annoying issue, The program itself works great except when I go and set it to start at login.

I've been testing it by logging off and in. The program starts when I log in but is hidden behind the desktop. When I click the app icon in the dockbar it comes to the front where it should have been to begin with.

The question is.. Has anyone encountered this issue and how should I fix it? I want the program to be visible on the desktop as soon as the computer logs in. I haven't had issues with this when working with IB but I am using NSRects to draw almost everything.

Any thoughts on this issue could be helpful. Thanks!

A: 

I have something like this in one of my apps that seems to work pretty well:

// open window and force to the front
[preferencesWindow makeKeyAndOrderFront:nil];
[preferencesWindow orderFrontRegardless];
[preferencesWindow center];

Try that out and see what happens. Obviously you don't need the [preferencesWindow center] if you don't want it centered.

codykrieger
Those all work and I have been trying to see if they can fix this issue but its weird. The application starts at login just fine but its behind the desktop. I have to click the icon again to get it to come to the front and once its there it says there. All my other programs work fine with similar code I can't quite figure it out.Thanks for the help tho Looks like I'm going to have to mess with it more.
Rugluds
Sure, let us know if you find the solution. Sorry I couldn't be of more help!
codykrieger
Well I found maybe something that is causing issues the Application is set in the plist to be a UIElement cause I would like the application to not act normally for my own reasons such as it shouldn't have an icon displayed in the dock while its on. I have another app I have set that on too but it displays fine at login. If I take the option off the application can launch just fine.
Rugluds
+2  A: 

I found the solution to my question. It has to do with the fact that my app is an LSUIElement app since I am making it for store demo machines. the reason I couldn't see my windows on launch is because of the way LSUIElements work so I had to tell it to do a few things

[[NSApplication sharedApplication]activateIgnoringOtherApps:YES];
[window orderFrontRegardless];
[window makeKeyWindow]; 
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];

after that it seems to have worked.

Rugluds
Good find, thanks for sharing.
codykrieger
welcome it worked great after testing it for awhile so if you need to make a LSUIElement app and need its windows to come to the front on login this should help some.
Rugluds