Re: MacOS: nonmodal NSAlert panel
> On 12 May 2021, at 11:17 am, Carl Hoefs via Cocoa-dev > wrote: > > I'd like to present an informational alert for n seconds then dismiss it > without user interaction. But I don't see any way to dismiss, terminate, > cancel, invalidate, etc. an NSAlert object. I recently did that exact thing, like this: > let alert = NSAlert() > // ... > > var countdown = 10 > func updateMessage() { > alert.informativeText = "This message will dismiss in \(countdown) > second\(countdown == 1 ? "" : "s")." > countdown -= 1 > } > let timer = Timer(timeInterval: 1.0, repeats: true) { timer in > if countdown == 0 { > timer.invalidate() > NSApp.abortModal() > } else { > updateMessage() > } > } > updateMessage() > RunLoop.main.add(timer, forMode: .common) > > alert.runModal() The key is `abortModal()`. -ben ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: MacOS: nonmodal NSAlert panel
On 5/12/21 11:17 AM, Carl Hoefs via Cocoa-dev wrote: I had thought it was possible on MacOS to run an NSAlert panel nonmodally... I'd like to present an informational alert for n seconds then dismiss it without user interaction. But I don't see any way to dismiss, terminate, cancel, invalidate, etc. an NSAlert object. I know this is possible in iOS, but is there no way to do this in MacOS, other than displaying/hiding an NSPanel of my own? An alternative would be CFUserNotificationDisplayNotice, which takes a timeout period as a parameter. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: MacOS: nonmodal NSAlert panel
I believe Apple uses NSPopOver for non-modal alerts and dialogs, which can automatically dismiss when the user clicks outside the popover. Keary Suska Esoteritech, Inc. "Demystifying technology for your home or business" > On May 12, 2021, at 12:17 PM, Carl Hoefs via Cocoa-dev > wrote: > > I had thought it was possible on MacOS to run an NSAlert panel nonmodally... > > I'd like to present an informational alert for n seconds then dismiss it > without user interaction. But I don't see any way to dismiss, terminate, > cancel, invalidate, etc. an NSAlert object. > > I know this is possible in iOS, but is there no way to do this in MacOS, > other than displaying/hiding an NSPanel of my own? > > -Carl > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40esoteritech.com > > This email sent to cocoa-...@esoteritech.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: MacOS: nonmodal NSAlert panel
> On May 12, 2021, at 11:17 AM, Carl Hoefs via Cocoa-dev > wrote: > > I had thought it was possible on MacOS to run an NSAlert panel nonmodally… Alerts are modal by definition, per the HIG (IIRC). If you want a non-modal panel, it wouldn't be an alert; you'd have to implement it yourself using an NSPanel. —Jens ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
MacOS: nonmodal NSAlert panel
I had thought it was possible on MacOS to run an NSAlert panel nonmodally... I'd like to present an informational alert for n seconds then dismiss it without user interaction. But I don't see any way to dismiss, terminate, cancel, invalidate, etc. an NSAlert object. I know this is possible in iOS, but is there no way to do this in MacOS, other than displaying/hiding an NSPanel of my own? -Carl ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com