Hello Michael.
So...after your suggestion, I nailed it :)
I open my custom UI in a pop-up dialog and I manage all the shortcuts is this way:
code:
<script>
var cmds = [];
cmds[parseInt("0x31")] = "line";
cmds[parseInt("0x32")] = "curve";
... other commands ...
var cmdsAlt = [];
cmdsAlt[parseInt("0x31")] = "polyline";
cmdsAlt[parseInt("0x32")] = "interpcurve";
... other commands ...
var cmdsCtrl = [];
cmdsCtrl[parseInt("0x35")] = "circletangent";
cmdsCtrl[parseInt("0x36")] = "arccontinue";
... other commands ...
var cmdsShift = [];
cmdsShift[parseInt("0x32")] = "sketchcurve";
cmdsShift[parseInt("0x33")] = "rect3pts";
... other commands ...
function OnKeyDownEvent(e) {
e.handled = true;
var cmdName = null;
if (e.shift) {
cmdName = cmdsShift[e.keyCode];
} else if (e.ctrl) {
cmdName = cmdsCtrl[e.keyCode];
} else if (e.alt) {
cmdName = cmdsAlt[e.keyCode];
} else {
cmdName = cmds[e.keyCode];
}
if (!cmdName) {
return;
}
moi.command.execCommand(cmdName);
moiWindow.close();
}
</script>
Then I also use a "fake" class to attach the "moiWindow.close();" command to all the moi:CommandButton that I use in the dialog:
code:
<moi:CommandButton class="myCmd" ...
<script type="text/javascript">
var buttons = document.querySelectorAll(".myCmd");
for (var i = 0; i < buttons.length; i++) {
buttons[i].addEventListener("click", function (event) {
moiWindow.close();
});
}
</script>
I hope you will ad soon the capability of trapping key event also in pop-up menu.
Thanks and have a nice day.
|