Finally, it works!
Although, how do you use this on a check box? Can it be applied to a true/false variable, because I have tried that, and that doesn't seem to do anything, in terms of what it's supposed to.
Perhaps the code below will help to explain. This is the bit where it does commands based on what button you press. The highlighted bit refers to a checkbox in a window.
js code:
var settingEnable = false;
var settingMessage = "/nudge";
var settingTimer = "1000";
var setnoteMesCmd = true;
var setMsgPlusAM = true;
var setSignInAlert = true;
function OnWndControlEvent_CtrlClicked(objWnd, strControlId)
{
switch(strControlId)
{
case "BtnEnable":
if (settingEnable)
{
}
else
{
settingEnable = true;
var Message = "Activation: enabled";
Message = MsgPlus.RemoveFormatCodes(Message);
MsgPlus.DisplayToast("Instant Response", Message);
Debug.Trace("Instant Response | Activation: enabled");
}
break;
case "BtnDisable":
if (settingEnable)
{
settingEnable = false;
var Message = "Activation: disabled";
Message = MsgPlus.RemoveFormatCodes(Message);
MsgPlus.DisplayToast("Instant Response", Message);
Debug.Trace("Instant Response | Activation: disabled");
}
else
{
}
break;
case "BtnSave":
if (settingMessage==objWnd.GetControlText("EditMessage"))
{
}
else if (objWnd.GetControlText("EditMessage") == "")
{
var Message = "New message was not set:\n message was left blank!";
Message = MsgPlus.RemoveFormatCodes(Message);
MsgPlus.DisplayToast("Instant Response", Message);
Debug.Trace("Instant Response | New message was not set: message was left blank!");
}
else
{
settingMessage = objWnd.GetControlText("EditMessage");
var Message = "New message: " + settingMessage;
Message = MsgPlus.RemoveFormatCodes(Message);
MsgPlus.DisplayToast("Instant Response", Message);
Debug.Trace("Instant Response | New message: " + settingMessage);
setnoteMesCmd = (/^\/[^\s\/]+\s*[\s\S]*$/.test(settingMessage));
objWnd.Close(1);
break;
}
if (settingTimer==objWnd.GetControlText("EditTimer"))
{
var Message = "New timer was not set:\n timer was left blank!";
Message = MsgPlus.RemoveFormatCodes(Message);
MsgPlus.DisplayToast("Instant Response", Message);
Debug.Trace("Instant Response | New timer was not set: timer was left blank!");
}
else if (objWnd.GetControlText("EditTimer")=="")
{
var Message = "New timer was not set:\n timer was left blank!";
Message = MsgPlus.RemoveFormatCodes(Message);
MsgPlus.DisplayToast("Instant Response", Message);
Debug.Trace("Instant Response | New timer was not set: timer was left blank!");
}
else if (objWnd.GetControlText("EditTimer")<100)
{
var Message = "New timer was not set:\ntimer was under 100ms!";
Message = MsgPlus.RemoveFormatCodes(Message);
MsgPlus.DisplayToast("Instant Response", Message);
Debug.Trace("Instant Response | New timer was not set: timer was under 100ms!");
}
else if (typeof parseInt(objWnd.GetControlText("EditTimer")) === 'number' ? parseInt(objWnd.GetControlText("EditTimer")) : 0)
{
settingTimer = objWnd.GetControlText("EditTimer");
var Message = "New timer: " + settingTimer + "ms";
Message = MsgPlus.RemoveFormatCodes(Message);
MsgPlus.DisplayToast("Instant Response", Message);
Debug.Trace("Instant Response | New timer: " + settingTimer + " milliseconds");
objWnd.Close(1);
break;
}
else
{
var Message = "New timer was not set:\ntimer used invalid characters!";
Message = MsgPlus.RemoveFormatCodes(Message);
MsgPlus.DisplayToast("Instant Response", Message);
Debug.Trace("Instant Response | New timer was not set: timer used invalid characters!");
}
>>> if (setMsgPlusAM==objWnd.GetControlText("ChkPlusAMStyle"))<<<
>>> { <<<
>>> } <<<
>>> else <<<
>>> { <<<
>>> setMsgPlusAM = objWnd.GetControlText("ChkPlusAMStyle"); <<<
>>> var Message = "Plus! style: " + setMsgPlusAM; <<<
>>> Message = MsgPlus.RemoveFormatCodes(Message); <<<
>>> MsgPlus.DisplayToast("Instant Response", Message); <<<
>>> Debug.Trace("Instant Response | Plus! style: " + setMsgPlusAM); <<<
>>> } <<<
objWnd.Close(1);
case "BtnCancel":
objWnd.Close(1);
break;
}
}