开发者

NSPanel set at the Desktopwindowlevel +1 issue with visible at login

开发者 https://www.devze.com 2023-01-11 14:17 出处:网络
This is a rather annoying issue, The program itself works great except when I go and set it to start at login.

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!


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号