PureBasic Forum
https://www.purebasic.fr/english/

Bring Window to the Front
https://www.purebasic.fr/english/viewtopic.php?f=19&t=75054
Page 1 of 1

Author:  ColBoy [ Wed Apr 08, 2020 3:13 pm ]
Post subject:  Bring Window to the Front

I've written a cross platform application for Windows and Mac. It sits on the system tray and when there is a trigger, a window pops up. On Windows I can force the window to the top, so it is always visible, no matter what application I am working on. For the Mac, I can't seem to find the same functionality. So in essence I want to unhide a window, which works, but also make this window appear foremost. Does anyone have any pointers for achieving this?

Thanks

Author:  Kiffi [ Wed Apr 08, 2020 3:16 pm ]
Post subject:  Re: Bring Window to the Front

StickyWindow() does not work on a Mac?

Greetings ... Peter

Author:  Wolfram [ Wed Apr 08, 2020 4:14 pm ]
Post subject:  Re: Bring Window to the Front

Maybe you need to bring the whole program to front.

Code:
#NSApplicationActivateAllWindows = 1 << 0
#NSApplicationActivateIgnoringOtherApps = 1 << 1

currentApplication = CocoaMessage(0, 0, "NSRunningApplication currentApplication")
CocoaMessage(0, currentApplication, "activateWithOptions:", #NSApplicationActivateAllWindows | #NSApplicationActivateIgnoringOtherApps)

Author:  ColBoy [ Wed Apr 08, 2020 4:26 pm ]
Post subject:  Re: Bring Window to the Front

Kiffi wrote:
StickyWindow() does not work on a Mac?

Greetings ... Peter

Thanks Peter, wasn't even aware of that one. Works well.

Author:  ColBoy [ Wed Apr 08, 2020 4:27 pm ]
Post subject:  Re: Bring Window to the Front

Wolfram wrote:
Maybe you need to bring the whole program to front.

Code:
#NSApplicationActivateAllWindows = 1 << 0
#NSApplicationActivateIgnoringOtherApps = 1 << 1

currentApplication = CocoaMessage(0, 0, "NSRunningApplication currentApplication")
CocoaMessage(0, currentApplication, "activateWithOptions:", #NSApplicationActivateAllWindows | #NSApplicationActivateIgnoringOtherApps)

Thanks Wolfram. HAven't checked this one as the other works and also gives me the benefit of having the same code for Windows.

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/