Skip to content

Commit

Permalink
Fix issue #32. Correcting multiple slashes in message box text.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary Willoughby committed Dec 20, 2015
1 parent 0efc805 commit fac8c5c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
6 changes: 3 additions & 3 deletions source/example/example.d
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
}

Expand Down
26 changes: 24 additions & 2 deletions source/tkd/window/dialog/messagedialog.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit fac8c5c

Please sign in to comment.