diff --git a/source/example/example.d b/source/example/example.d index 3a596aa..ec740a0 100644 --- a/source/example/example.d +++ b/source/example/example.d @@ -120,7 +120,7 @@ class Application : TkdApplication */ private void openMessageDialog(CommandArgs args) { - auto dialog = new MessageDialog() + auto dialog = new MessageDialog(this.mainWindow) .setMessage("Lorem ipsum dolor sit amet.") .setDetailMessage("Nunc at aliquam arcu. Sed eget tellus ligula.\nSed egestas est et tempus cursus.") .setType(MessageDialogType.okcancel) @@ -155,9 +155,9 @@ class Application : TkdApplication */ private void showAbout(CommandArgs args) { - auto dialog = new MessageDialog("About") + auto dialog = new MessageDialog(this.mainWindow, "About") .setMessage("Tkd Showcase") - .setDetailMessage("An showcase Tkd application demonstrating menus, widgets and dialogs.\n\nThe possiblities are endless.") + .setDetailMessage("A showcase Tkd application demonstrating menus, widgets and dialogs.\n\nThe possiblities are endless.") .show(); } diff --git a/source/tkd/window/dialog/messagedialog.d b/source/tkd/window/dialog/messagedialog.d index 0b1b160..7124a33 100644 --- a/source/tkd/window/dialog/messagedialog.d +++ b/source/tkd/window/dialog/messagedialog.d @@ -216,15 +216,37 @@ class MessageDialog : Dialog { this.checkDefaultButton(); + // String concatenation is used to build the script here instead of + // using format specifiers to enable supporting input which includes + // Tcl/Tk reserved characters and elements that could be construed as + // format specifiers. + string script; + if (this._parent) { - this._tk.eval("tk_messageBox -parent %s -title {%s} -default {%s} -detail {%s} -icon {%s} -message {%s} -type {%s}", this._parent.id, this._title, this._defaultButton, this._detailMessage, this._icon, this._message, this._type); + script = std.conv.text( + `tk_messageBox -parent `, this._parent.id, + ` -title {`, this._title, `}`, + ` -default {`, this._defaultButton, `}`, + ` -detail {`, this._detailMessage, `}`, + ` -icon {`, this._icon, `}`, + ` -message {`, this._message, `}`, + ` -type {`, this._type, `}` + ); } else { - this._tk.eval("tk_messageBox -title {%s} -default {%s} -detail {%s} -icon {%s} -message {%s} -type {%s}", this._title, this._defaultButton, this._detailMessage, this._icon, this._message, this._type); + script = std.conv.text( + `tk_messageBox -title {`, this._title, `}`, + ` -default {`, this._defaultButton, `}`, + ` -detail {`, this._detailMessage, `}`, + ` -icon {`, this._icon, `}`, + ` -message {`, this._message, `}`, + ` -type {`, this._type, `}` + ); } + this._tk.eval(script); this._results = [this._tk.getResult!(string)]; return cast(T) this;