0

I would like to know when a window that is in background becomes the frontmost window.

I read this question but it works to know what window is the frontmost and not when the window becomes the frontmost window: How to know if a NSWindow is the front window?

I implemented this code but unfortunately it is called only when the window is opened not when it comes back to foreground

override func viewDidAppear() {
    let a = variables.actionToAddToCurrentWorkflow
    if a != "" {
        actionItems.append(a)
        actionsListTableView.reloadData()
    }
}

Being a beginner would appreciate a lot if it was possible to have a sample code as well.

Cue
  • 2,952
  • 3
  • 33
  • 54

1 Answers1

1

Observe the notification NSWindowDidBecomeMain. The object of the notification is the window which became frontmost.

vadian
  • 274,689
  • 30
  • 353
  • 361