ui icon indicating copy to clipboard operation
ui copied to clipboard

Window to front

Open mainrs opened this issue 7 years ago • 8 comments

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

mainrs avatar Sep 26 '16 12:09 mainrs

What OS? What scenario?

andlabs avatar Sep 26 '16 14:09 andlabs

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.

mainrs avatar Sep 26 '16 19:09 mainrs

See https://github.com/andlabs/libui/pull/20#issuecomment-211381971

andlabs avatar Sep 26 '16 19:09 andlabs

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

ereli avatar Dec 28 '16 18:12 ereli

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 avatar Dec 29 '16 02:12 andlabs

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

andlabs avatar Feb 09 '19 18:02 andlabs

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?

andrewarrow avatar Jul 26 '19 00:07 andrewarrow

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.

uchuugaka avatar Jul 26 '19 01:07 uchuugaka