Skip to content

Commit

Permalink
Add usage examples
Browse files Browse the repository at this point in the history
  • Loading branch information
harryjph committed Jun 22, 2021
1 parent 3c6a661 commit 67c2bfa
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 8 deletions.
4 changes: 3 additions & 1 deletion _examples/notusingutil/OpenFile.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ func main() {
log.Fatal(err)
}
result, err := openDialog.GetResult()
if err != nil {
if err == cfd.ErrorCancelled {
log.Fatal("Dialog was cancelled by the user.")
} else if err != nil {
log.Fatal(err)
}
log.Printf("Chosen file: %s\n", result)
Expand Down
4 changes: 3 additions & 1 deletion _examples/notusingutil/OpenMultipleFiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ func main() {
log.Fatal(err)
}
results, err := openMultiDialog.GetResults()
if err != nil {
if err == cfd.ErrorCancelled {
log.Fatal("Dialog was cancelled by the user.")
} else if err != nil {
log.Fatal(err)
}
log.Printf("Chosen file(s): %s\n", results)
Expand Down
4 changes: 3 additions & 1 deletion _examples/notusingutil/PickFolder.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ func main() {
log.Fatal(err)
}
result, err := pickFolderDialog.GetResult()
if err != nil {
if err == cfd.ErrorCancelled {
log.Fatal("Dialog was cancelled by the user.")
} else if err != nil {
log.Fatal(err)
}
log.Printf("Chosen folder: %s\n", result)
Expand Down
4 changes: 3 additions & 1 deletion _examples/notusingutil/SaveFile.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ func main() {
log.Fatal(err)
}
result, err := saveDialog.GetResult()
if err != nil {
if err == cfd.ErrorCancelled {
log.Fatal("Dialog was cancelled by the user.")
} else if err != nil {
log.Fatal(err)
}
log.Printf("Chosen file: %s\n", result)
Expand Down
4 changes: 3 additions & 1 deletion _examples/usingutil/OpenFile.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ func main() {
FileName: "file.txt",
DefaultExtension: "txt",
})
if err != nil {
if err == cfd.ErrorCancelled {
log.Fatal("Dialog was cancelled by the user.")
} else if err != nil {
log.Fatal(err)
}
log.Printf("Chosen file: %s\n", result)
Expand Down
4 changes: 3 additions & 1 deletion _examples/usingutil/OpenMultipleFiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ func main() {
FileName: "file.txt",
DefaultExtension: "txt",
})
if err != nil {
if err == cfd.ErrorCancelled {
log.Fatal("Dialog was cancelled by the user.")
} else if err != nil {
log.Fatal(err)
}
log.Printf("Chosen file(s): %s\n", results)
Expand Down
4 changes: 3 additions & 1 deletion _examples/usingutil/PickFolder.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ func main() {
Role: "PickFolderExample",
Folder: "C:\\",
})
if err != nil {
if err == cfd.ErrorCancelled {
log.Fatal("Dialog was cancelled by the user.")
} else if err != nil {
log.Fatal(err)
}
log.Printf("Chosen folder: %s\n", result)
Expand Down
4 changes: 3 additions & 1 deletion _examples/usingutil/SaveFile.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ func main() {
FileName: "image.jpg",
DefaultExtension: "jpg",
})
if err != nil {
if err == cfd.ErrorCancelled {
log.Fatal("Dialog was cancelled by the user.")
} else if err != nil {
log.Fatal(err)
}
log.Printf("Chosen file: %s\n", result)
Expand Down

0 comments on commit 67c2bfa

Please sign in to comment.