Menu

#1206 UniversalInputDialog: exec() does not return null

None
fixed
nobody
1
2015-01-21
2015-01-19
crumbedfish
No

Windows 8.1 Pro 64-bit
TeXstudio 2.8.8 (hg 4828+:0a999280f5cb+)

According to the manual, the UniversalInputDialog.exec() method "Displays the dialog. Returns null, if the user cancels it, and the values of getAll(), if he accepts it.". However, the following macro always enters the first if branch even if the user cancels the dialog...

%SCRIPT
dialog = new UniversalInputDialog()
dialog.setWindowTitle("Test Dialog")
dialog.add("Sample input", "Comment", "comment")
if (dialog.exec() != null) {
    alert("Dialog was okayed.")
}
else {
    alert("Dialog was cancelled.")
}

Discussion

  • hair-splitter

    hair-splitter - 2015-01-19

    Use "" instead of null.

     
  • crumbedfish

    crumbedfish - 2015-01-19

    Ok, thanks.. but in that case the documentation needs to be updated as well as existing scripts. For example, https://sourceforge.net/p/texstudio/wiki/Scripts/#git-commit-and-push uses dialog.exec() != null.

     
  • Tim Hoffmann

    Tim Hoffmann - 2015-01-21

    Actually the return value is an integer: 1 if the dialog was accepted, 0 if it was canceled.

    I've updated the documentation.

     
  • Tim Hoffmann

    Tim Hoffmann - 2015-01-21
    • status: open --> fixed
    • Group: -->
     

Log in to post a comment.

MongoDB Logo MongoDB