Hi,
I changed the code to this and it works correctly.
Can't tell you why exactly, but I think it is to do with the dialog being global.
// BareBone.jsx ====== UTF-8 =======================================================================
// --- Globals -----------------------------------
if (typeof KLD_G == "undefined") {
KLD_G = {}; // Global script object for this suite
}
KLD_G.msgInfo = true; // Informative messages
KLD_G.msgWarn = true; // Warnings
KLD_G.msgError = true; // Error messages
KLD_G.Main = function () { // =====================================================================
KLD_G.SetUpMenus();
}; // -- end Main -------------------------------------------------------------------------------
KLD_G.SetUpMenus = function () { // ===============================================================
var docFMgraphMenu, menuLocation, oMenus = {}, oCmd = {};
// --- Menu entries (could be integrated in to command definitions as strings)
oMenus.MenuMain = "BareBone Graphic Library";
oMenus.SetMessages = "Re/Set messages";
// --- Command definition for documents
oCmd.MsetMessages = DefineCommand(5, "FMgraph_SetMessages", oMenus.SetMessages, "\!qgmo");
// --- Shortcut labels
oCmd.MsetMessages.KeyboardShortcutLabel = "ESC q g m";
// --- Assign commands to menus
menuLocation = app.GetNamedMenu("GraphicsMenu"); // look up name in the menus.cfg files
docFMgraphMenu = menuLocation.DefineAndAddMenu("!FMgraphMain", oMenus.MenuMain); // ! required
docFMgraphMenu.AddCommandToMenu(oCmd.MsetMessages);
//
UpdateMenus(); // refresh and actually make the new menu appear
}; //-- end SetUpMenus ---------------------------------------------------------------------------
function Command(cmd) { // =======================================================================
switch (cmd) {
case 5:
KLD_G.SetMessages();
break;
}
} //-- end Command ------------------------------------------------------------------------------
KLD_G.SetMessages = function () { // ==============================================================
KLD_G.DlgSetMessages();
}; //-- end DlgSetMessages ------------------------------------------------------------------------
KLD_G.DlgSetMessages = function () { // ============================================================
var wDlgM = new Window("dialog", undefined, undefined); // title set in DlgM
// This does not work as dialog, only as palette - see development log.
wDlgM.text = "BareBone version of FMgraph to demonstrate the dialog problem";
wDlgM.preferredSize.width = 250;
wDlgM.orientation = "column";
wDlgM.alignChildren = ["left", "top"];
wDlgM.spacing = 10;
wDlgM.margins = 5;
wDlgM.chkI = wDlgM.add("checkbox", undefined, "I: Information messages ");
wDlgM.chkW = wDlgM.add("checkbox", undefined, "W: Warning messages");
wDlgM.chkE = wDlgM.add("checkbox", undefined, "E: Error messages");
wDlgM.btnSet = wDlgM.add("button", undefined, "Set messag display");
// ---------------------------------------------------- behaviour of the buttons ------------------
wDlgM.btnSet.onClick = function () {
KLD_G.msgInfo = wDlgM.chkI.value;
KLD_G.msgWarn = wDlgM.chkW.value;
KLD_G.msgError = wDlgM.chkE.value;
wDlgM.close();
};
// ---------------------------------------------------- Final work in dialogue --------------------
wDlgM.chkI.value = KLD_G.msgInfo; // Informative messages
wDlgM.chkW.value = KLD_G.msgWarn; // Warnings
wDlgM.chkE.value = KLD_G.msgError; // Error messages
wDlgM.show();
}; //=== end DlgSetMessages <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
// <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
KLD_G.Main(); // === follow the standard