Accelerator keys: Problems with digits in drop-down menus

Once again in the interest of perfection, here is a button-script producing a dialogue with drop-down buttons:

function OnClick (clickData) { var oDlg = DOpus.dlg oDlg.message = "Choose a button." var sButtonsLetters = "&A. Alpha + Other1=&A. Alpha Other1+ Other2=&A. Alpha Other2+ Other3=&A. Alpha Other3|&B. Bravo + Other1=&B. Bravo Other1+ Other2=&B. Bravo Other2+ Other3=&B. Bravo Other3|" var sButtonsDigits = "&1. One + Other1=&1. One Other1+ Other2=&1. One Other2+ Other3=&1. One Other3|&2. Two + Other=&2. Two Other1+ Other2=&2. Two Other2+ Other3=&2. Two Other3|" oDlg.buttons = sButtonsLetters + sButtonsDigits + "&0. Cancel" nChoice = oDlg.show DOpus.Output ("nChoice = " + nChoice) }

  1. The five accelerator keys A, B, 1, 2, 0 all work perfectly when the arrows are not being used.
  2. When Shift is held down, the letter accelerator keys Shift+A and Shift+B work, but the digit accelerator keys Shift+1, Shift+2 and Shift+0 do not.
  3. When Ctrl is held down, none of the five accelerator keys work.
  4. When Shift + Ctrl is held down, none of the five accelerator keys work.

If &0. Cancel is replaced by &Cancel, then C and Shift+C work, but Ctrl+C and Shift+Ctrl+C do not.

Point 2 is the clear inconsistency between letters and digits. It would be nice if points 3 and 4 were also sorted out by activating the accelerator keys.

That button code is a mixture of VBScript and JScript, and does not run.

It does here, it shows the dialog and buttons at least and no errors in the console.
I can also confirm what Julianon sees in Point #2.

Pasting it as-is (so it would run as VBScript):

Error at line 1, position 30 Function OnClick (clickData) { ^ Invalid character (0x800a0408) Parse error - script aborted

Adding @script jscript to the top:

Error at line 2, position 10 Function OnClick (clickData) { ^ Expected ';' (0x800a03ec) Parse error - script aborted

Point #2 sounds like what I would expect, since shift + digits are no longer those digits. But until I can run the script I am not sure if what I think it's trying to do is what it is really trying to do / doing.

"function" for jscript, it needs to be lowercase and I guess it's not anymore because you were in vbmode before?

It's JScript — I've never written any VBScript — the line breaks must have mucked things up. Here it is with shorter lines (and I've checked that the code copied from the Preview still runs on my system).

@Script JScript function OnClick (clickData) { var oDlg = DOpus.dlg oDlg.message = "Choose a button." var sA = "&A. Alpha + Other1=&A. Alpha Other1+ Other2=&A. Alpha Other2+ Other3=&A. Alpha Other3|" var sB = "&B. Bravo + Other1=&B. Bravo Other1+ Other2=&B. Bravo Other2+ Other3=&B. Bravo Other3|" var s1 = "&1. One + Other1=&1. One Other1+ Other2=&1. One Other2+ Other3=&1. One Other3|" var s2 = "&2. Two + Other=&2. Two Other1+ Other2=&2. Two Other2+ Other3=&2. Two Other3|" oDlg.buttons = sA + sB + s1 + s2 + "&Cancel" nChoice = oDlg.show DOpus.Output ("nChoice = " + nChoice) }

Found the problem. Pasting it as-is gets VBScript syntax highlighting which also uppercases the f in Function when you paste, and changing it to JScript after pasting makes JScript rejects the word "Function" because Javascript is case-sensitive to a ridiculous degree. :slight_smile:

Now I can see what we're doing: Point #2 is as I said above. Shift + digits are no longer those digits.

Where does the Other1=&A. Alpha Other1 syntax come from?

If you look at Opus's own dialogs which use these buttons (e.g. the Replace File dialog), the idea is to give the menu items distinct accelerators, not copy the accelerator from the parent button. Those keys then work after the menu has been opened (by tabbing to the button and pushing the down arrow key).

I'm not sure there is a supported way to provide direct keyboard access to those menu items; you have to open the menu first.

The shift / ctrl / shift+ctrl shortcuts for the first three items in a menu are so you can quickly access those choices by holding those keys and clicking the button with the mouse.

leo, I got the syntax from the Help file manual, which for some reason goes into more detail than the online manual yet does. In the Help file, look at:
Reference - - > Scripting Reference - - > Scripting Objects - - > Dialog - - > buttons
I found the syntax there hard to understand, but I managed to sort it out from the given examples. Then I added the usual accelerator keys, which are not specifically mentioned in the Help file manual, and found what seems to be an unsystematic situation:

  • With Shift, letters work, but numbers don't.
  • With Ctrl and Ctrl+Shift, neither letters nor numbers work.
    It looks like nothing more than an easily fixed glitch.

By the way, I know very well that you can tab or left-right-arrow to the button you want, then press down-arrow, and then pick out the thing you want (in which case of course I would have used different first letters), but that's not what I am concerned about.

Button accelerators aren't case sensitive, so a and A are treated as the same key. But Shift+1 is a !, not a 1 - it's a different character altogether.

jon, you've nailed it! I replaced the second accelerator keys 1 and 2 by ! and @ respectively, and this time they worked. (I'm not at all sure that this is a smart thing to do, but at least it confirms what you say.) And my apologies to leo, who was trying valiantly to tell me the same thing.

That would also explain why Ctrl is not working as an accelerator key, so answering my points 3 and 4 as well.

Order is now restored in the kingdom.