I am new to osx programming. I am using pyobjc to create the alerts. My understanding of Modal windows or dialogs is that modal windows require the user’s action before they can proceed. However, if I use runModal of NSAlert, I am still able to goto other apps while the alert is still shown. Is my understanding of modal dialogs incorrect.
class Alert(object):
def __init__(self, messageText):
super(Alert, self).__init__()
self.messageText = messageText
self.informativeText = ""
self.buttons = []
def displayAlert(self):
alert = NSAlert.alloc().init()
alert.setMessageText_(self.messageText)
alert.setInformativeText_(self.informativeText)
# alert.setAlertStyle_(NSInformationalAlertStyle)
alert.setAlertStyle_(NSCriticalAlertStyle)
for button in self.buttons:
alert.addButtonWithTitle_(button)
NSApp.activateIgnoringOtherApps_(True)
self.buttonPressed = alert.runModal()
def alert(message="Default Message", info_text="", buttons=["OK"]):
ap = Alert(message)
ap.informativeText = info_text
ap.buttons = buttons
ap.displayAlert()
return ap.buttonPressed