Example: Creates PmForm window configured as MessageBox
In a single script (e.g. after pressing the button in the
onButtonUp event) a user defined MessageBox is created, that may contain some of the buttons
ok,
cancel,
yes,
no. The
Debug method in the
switch command can be replaced by any other command.
JavaScriptSelect and copy to clipboard
// Creates PmViewCreator - The object allows to open the various viewers
var oCreator = Pm.CreateView(null, "/#glob/form", "", "target:_blank;modal:1;");
oCreator.View.onLoad = function(ev)
{
// Creates a form object
var oForm = ev.Form;
oForm.Title = "MessageBox";
// oForm.SysLayoutPos = "bottom";
oForm.SysButtons = "ok,cancel";
// ok,cancel,yes,no
oForm.CreateItem("separ", "separ", "", "Subtype:space;TitlePos:no;BodyHeightIni:1;");
var oMsg = oForm.CreateItem("string", "msg", "", "Subtype:static;TitlePos:no;Multiline:1;ValueHorzAlign:center;");
oMsg.Value = "text for massage \\n YES/NO/OK/CANCEL";
// "\n" = new row
};
oCreator.View.onClose = function(ev)
{
switch (ev.CloseReason)
// "ok","cancel","yes","no"
{
case "ok":
Pm.Debug("ok");
break;
case "cancel":
Pm.Debug("cancel");
break;
case "yes":
Pm.Debug("yes");
break;
case "no":
Pm.Debug("no");
break;
}
};
// Opens form in a modal window:
oCreator.Open();