Skip to content

Commit 55fed6b

Browse files
committed
chart commands support integer modifiers
1 parent 3f98883 commit 55fed6b

File tree

1 file changed

+33
-19
lines changed

1 file changed

+33
-19
lines changed

mql40/include/rsf/functions/HandleCommands.mqh

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* Retrieve received commands and pass them to the command handler. Command format: "cmd[:params[:modifiers]]"
33
*
44
* cmd: command identifier (required)
5-
* params: one or more command parameters separated by comma "," (optional)
6-
* modifiers: one or more virtual key modifiers separated by comma "," (optional)
5+
* params: one or more command parameters separated by comma (optional)
6+
* modifiers: one or more virtual key modifiers separated by comma (optional)
77
*
88
* @param string channel [optional] - channel to check for commands (default: the program's standard command channel)
99
*
@@ -19,32 +19,46 @@ bool HandleCommands(string channel = "") {
1919
int size = ArraySize(commands);
2020

2121
for (int i=0; i < size && !last_error; i++) {
22-
string cmd="", params="", modifier="", values[];
22+
string cmd="", params="", modifiers="", sValue="", sValues[];
2323

24-
int parts = Explode(commands[i], ":", values, NULL), virtKeys=0;
25-
if (parts > 0) cmd = StrTrim(values[0]);
26-
if (parts > 1) params = StrTrim(values[1]);
24+
int parts = Explode(commands[i], ":", sValues, NULL), iValue=0, keys=0;
25+
if (parts > 0) cmd = StrTrim(sValues[0]);
26+
if (parts > 1) params = StrTrim(sValues[1]);
2727
if (parts > 2) {
28-
parts = Explode(values[2], ",", values, NULL);
29-
for (int n=0; n < parts; n++) {
30-
modifier = StrTrim(values[n]);
31-
if (modifier == "VK_ESCAPE") virtKeys |= F_VK_ESCAPE;
32-
else if (modifier == "VK_TAB") virtKeys |= F_VK_TAB;
33-
else if (modifier == "VK_CAPITAL") virtKeys |= F_VK_CAPITAL; // CAPSLOCK key
34-
else if (modifier == "VK_SHIFT") virtKeys |= F_VK_SHIFT;
35-
else if (modifier == "VK_CONTROL") virtKeys |= F_VK_CONTROL;
36-
else if (modifier == "VK_MENU") virtKeys |= F_VK_MENU; // ALT key
37-
else if (modifier == "VK_LWIN") virtKeys |= F_VK_LWIN; // left Windows key
38-
else if (modifier == "VK_RWIN") virtKeys |= F_VK_RWIN; // right Windows key
39-
else if (modifier != "") logNotice("HandleCommands(1) skipping unsupported key modifier: "+ modifier);
28+
modifiers = StrTrim(sValues[2]);
29+
if (StrIsDigits(modifiers)) {
30+
iValue = StrToInteger(modifiers);
31+
if (iValue & F_VK_ESCAPE && 1) keys |= F_VK_ESCAPE;
32+
if (iValue & F_VK_TAB && 1) keys |= F_VK_TAB;
33+
if (iValue & F_VK_CAPITAL && 1) keys |= F_VK_CAPITAL; // CAPSLOCK key
34+
if (iValue & F_VK_SHIFT && 1) keys |= F_VK_SHIFT;
35+
if (iValue & F_VK_CONTROL && 1) keys |= F_VK_CONTROL;
36+
if (iValue & F_VK_MENU && 1) keys |= F_VK_MENU; // ALT key
37+
if (iValue & F_VK_LWIN && 1) keys |= F_VK_LWIN;
38+
if (iValue & F_VK_RWIN && 1) keys |= F_VK_RWIN;
39+
}
40+
else {
41+
parts = Explode(modifiers, ",", sValues, NULL);
42+
for (int n=0; n < parts; n++) {
43+
sValue = StrTrim(sValues[n]);
44+
if (sValue == "VK_ESCAPE") keys |= F_VK_ESCAPE;
45+
else if (sValue == "VK_TAB") keys |= F_VK_TAB;
46+
else if (sValue == "VK_CAPITAL") keys |= F_VK_CAPITAL;
47+
else if (sValue == "VK_SHIFT") keys |= F_VK_SHIFT;
48+
else if (sValue == "VK_CONTROL") keys |= F_VK_CONTROL;
49+
else if (sValue == "VK_MENU") keys |= F_VK_MENU;
50+
else if (sValue == "VK_LWIN") keys |= F_VK_LWIN;
51+
else if (sValue == "VK_RWIN") keys |= F_VK_RWIN;
52+
else if (sValue != "") logNotice("HandleCommands(1) skipping unsupported key modifier: "+ sValue);
53+
}
4054
}
4155
}
4256

4357
if (cmd == "") {
4458
logNotice("HandleCommands(2) skipping empty command: \""+ commands[i] +"\"");
4559
continue;
4660
}
47-
onCommand(cmd, params, virtKeys);
61+
onCommand(cmd, params, keys);
4862
}
4963
}
5064
return(!last_error);

0 commit comments

Comments
 (0)