Alexander MacLeod
Alexander MacLeod

Reputation: 2026

Disable NSWindow Interaction

I am attempting to develop a custom NSAlert using NSWindow. When the custom alert NSWindow is triggered from the main application window, the user is still able to interact with the main window and access the menu bar whilst the alert window is still active. I believe when a NSAlert is presented, such actions are disabled and a 'Funk' sound is played upon any attempt to interact with the main window.

How would I disable interaction with the main window (and possibly play a 'Funk' sound) until the user has acted on the alert window?

Upvotes: 0

Views: 856

Answers (1)

Ken Thomases
Ken Thomases

Reputation: 90671

Run your custom window as a "modal" window. The simplest way is to use the runModal(for:) method of NSApplication. Actions which should complete or dismiss the modal dialog should call stopModal() or stopModal(withCode:).

Upvotes: 1

Related Questions