Skip to content
Open
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
4 changes: 3 additions & 1 deletion dialog.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func buildDialog(text string, options []string) string {
// dialog := mack.DialogOptions{
// Text: "Dialog text", // Required
// Title: "Dialog title", // Optional
// CollectAnswer: true, // Optional - If true, shows a text input to collect answer
// Answer: "Default answer", // Optional
// Duration: 5, // Optional
// HiddenAnswer: true, // Optional - If true, turns the input text to bullets
Expand All @@ -70,7 +71,7 @@ func buildDialogBox(dialog DialogOptions) string {
if dialog.Title != "" {
title = "with title " + wrapInQuotes(dialog.Title)
}
if dialog.Answer != "" {
if dialog.CollectAnswer || dialog.Answer != "" {
answer = "default answer " + wrapInQuotes(dialog.Answer)
}
if dialog.HiddenAnswer {
Expand Down Expand Up @@ -103,6 +104,7 @@ func buildDialogBox(dialog DialogOptions) string {
type DialogOptions struct {
Text string // The content of the dialog box
Title string // The title of the dialog box, displayed in emphasis
CollectAnswer bool // If true, shows a text input to collect answer
Answer string // The default text in the input field
HiddenAnswer bool // If true, converts the answer text to bullets (like a password field)
Icon string // The path to a .icns file, or one of the following: "stop", "note", "caution"
Expand Down
8 changes: 8 additions & 0 deletions dialog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ func TestBuildDialogBox(t *testing.T) {
}),
expected: "display dialog \"text\" with title \"title\"",
},
StringAssert{
actual: buildDialogBox(DialogOptions{
Text: "text",
Title: "title",
CollectAnswer: true,
}),
expected: "display dialog \"text\" with title \"title\" default answer \"\"",
},
StringAssert{
actual: buildDialogBox(DialogOptions{
Text: "text",
Expand Down