Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set NSWindow focused

I have an app winth one window and one panel, attached to this window.

steps:

  1. deactivate my app (app opened, but without the focus)
  2. click on a button on panel (panel is focused now, but main window is not)

How to set focus to the main window (parent window) from the panel?

like image 814
BUDDAx2 Avatar asked Feb 23 '11 10:02

BUDDAx2


1 Answers

Swift 5 version of @BUDDAx2 answer:

NSApplication.shared.activate(ignoringOtherApps: true)
like image 158
Starwave Avatar answered Sep 22 '22 05:09

Starwave