Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions examples/alertdialog.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Demonstrates windy alertDialog.
import windy

alertDialog("Windy Alert", "macOS NSAlert is working.")
echo "alert closed"
4 changes: 4 additions & 0 deletions src/windy/platforms/macos/macdefs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ type
NSDictionary* = distinct NSObject
NSOpenPanel* = distinct NSObject
NSSavePanel* = distinct NSObject
NSAlert* = distinct NSObject
NSURL* = distinct NSObject
NSFileManager* = distinct NSObject

Expand Down Expand Up @@ -186,6 +187,9 @@ objc:
proc setAllowedFileTypes*(self: NSSavePanel, x: NSArray)
proc runModal*(self: NSOpenPanel): int
proc runModal*(self: NSSavePanel): int
proc setMessageText*(self: NSAlert, x: NSString)
proc setInformativeText*(self: NSAlert, x: NSString)
proc runModal*(self: NSAlert): int
proc URLs*(self: NSOpenPanel): NSArray
proc URL*(self: NSSavePanel): NSURL
proc path*(self: NSURL): NSString
Expand Down
9 changes: 9 additions & 0 deletions src/windy/platforms/macos/platform.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,15 @@ proc allowedFileTypes(filters: seq[FileDialogFilter]): NSArray =
return 0.NSArray
result = (@(exts.join(","))).componentsSeparatedByString(@",")

proc alertDialog*(title, message: string) =
## Pops a blocking alert dialog.
init()
autoreleasepool:
let alert = NSAlert.new()
alert.setMessageText(@title)
alert.setInformativeText(@message)
discard alert.runModal()

proc openFileDialog*(
title = "Open File",
filters: seq[FileDialogFilter] = @[],
Expand Down
Loading