Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force Mac window to foreground?

How can I programmatically force a mac window to be the front window? I have the window handle, and want to ensure that my window is displayed above all other windows. I can use both Carbon & Cocoa for this.

like image 662
Thomi Avatar asked May 04 '10 08:05

Thomi


People also ask

How do you keep a window always in front on a Mac?

9. Open the window you want it to be on top. Then, click CTRL + SPACE. Then, you will see that the window will stay on top no matter which app you open later.

How do you float a window at the top of a Mac?

Updated at 07 Feb, 2022 07:25 PM. If you want Tot's window to float above other windows on the Mac desktop, use the "Display as Floating Window" item in the Window menu. Note that the Window menu is only visible when you're using Tot with a Dock icon.

How do you overlay windows on a Mac?

When you drag a window on your Mac, the layout view appears as an overlay on screen and you choose the one you want, and where you want the current window to sit in that layout. You can then add more windows to the it. Layouts can be organized in groups – such as those for two apps, three apps, etc.


1 Answers

For Cocoa, you can set the window level using:

[window setLevel:NSFloatingWindowLevel];

A floating window will display above all other regular windows, even if your app isn't active.

If you want to make your app active, you can use:

[NSApp activateIgnoringOtherApps:YES];

and

[window makeKeyAndOrderFront:nil];
like image 72
Ken Aspeslagh Avatar answered Sep 28 '22 09:09

Ken Aspeslagh