Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Window to front #194

Open
mainrs opened this issue Sep 26, 2016 · 8 comments
Open

Window to front #194

mainrs opened this issue Sep 26, 2016 · 8 comments

Comments

@mainrs
Copy link

mainrs commented Sep 26, 2016

Is there some way to bring the window to the front programmatically?

@andlabs
Copy link
Owner

andlabs commented Sep 26, 2016

What OS? What scenario?

@mainrs
Copy link
Author

mainrs commented Sep 26, 2016

It happens on OS X to me, I run the created executable from the command line. The window opens and centers as expected, but the focus doesnt switch to the application. The active application is still the terminal.

@andlabs
Copy link
Owner

andlabs commented Sep 26, 2016

See andlabs/libui#20 (comment)

@ereli
Copy link

ereli commented Dec 28, 2016

I understand it shouldn't be the default state, but is there another way to pass NSApp activateIgnoringOtherApps or NSApplicationActivateAllWindows ?

@andlabs
Copy link
Owner

andlabs commented Dec 29, 2016

Recently I found that some features of OS X, namely Dictation, only work if the program is run in a .app bundle, which will remove the need for this. I need to do some more investigation to see if this is actually the right way to go...

@andlabs
Copy link
Owner

andlabs commented Feb 9, 2019

Those methods are for starting a separate program from within your own.

@andrewarrow
Copy link

looking for an ez solution for this one. Maybe after each build I can just throw the binary into the right folder structure and rename .app?

@uchuugaka
Copy link

Those methods are for starting a separate program from within your own.

indeed! I must have been half asleep. Aaaaand, now I remember why I wrote that. The point was, those NSWorkspace methods are the equivalent of activation. You can absolutely tell the workspace to activate you in that way. Then, it in turn goes through Launch Services, because, those methods directly wrap the long deprecated LS prefixed Launch Services functions that could do the same. By going through Launch Services via NSWorkspace, it is behaving much much more the way a user activating you app in the UI behaves. It removes the unfair contention of focus stealing, removes the unnatural behavior and allows for user interactions on the system to order focus and activations as normal. It might seem backward and roundabout but it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants