Shortcuts for tools

Would like to canvas opinion on something. I think it would make Avogadro even more convenient to use if the user could rapidly switch between tools using keyboard shortcuts. Do people agree?

Building a molecule would be even easier if we didn’t have to move the mouse away from the view window while rapidly switching between e.g. rotating and drawing, or selecting and manipulating.

Since the alphabetic keys are used as shortcuts for the Draw Tool to change elements, for example, I thought the most convenient would be to use the numeric keys to activate the tools. They would simply be numbered in sequence across the toolbar, so 1 for Navigation, 2 for Draw, etc. But I am open to other suggestions.

For once this isn’t me suggesting yet more work for other people, I have already started on implementing something, and almost have it working – I opened a WIP pull request. :slight_smile:

  • Like the idea, like the suggestion of the numeric keys
  • Like the idea, prefer a different set of shortcuts
  • Don’t like the idea, we don’t need shortcuts for this
0 voters

I like the idea - we already have numeric shortcuts for tools, numbered in sequence across the toolbar. :wink:

The code that does the assignment is in avogadroapp

I like the idea, because e.g., in ChemDraw hoovering the mouse over a bond and typing 2 alters it into a double bond, a 3 into a triple, a 1 back into a single bond.

Additional shortcuts which perhaps equally can be implemented in Avogadro could be

  • + and - to gradually zoom in and out, complemented by one which rescales the visualization back home for an overview (e.g., = as in sxiv)
  • rotations around the geometric center in increments of for instance 10 degrees, and translations by 10% screen estate bound to something “intuitive”. E.g., one set of moves by vim-like hjkl, the other with HJKL. Or/and arrow left/arrow right/arrow up/arrow down either pressed alone, or simultaneously to Shift or Ctrl key.

Oops really? I had no idea! Ok then, I’ll make sure to mention it in the docs then, and see if I can add it to the tool tips that come up when you hover over the tools to help discoverability.

How would you feel about changing it from Ctrl+1 etc. to just the numbers without Ctrl to make it easier to switch while keeping one hand on the mouse?

That, and the similar behaviour for atoms, was exactly the inspiration!

I like the idea of using the arrow keys for this, and also the idea of it being in discrete increments. How about each translation key press moves the centre of the view by exactly 1 angstrom?

I’m not sure that’s possible – certainly not cross-platform. Feel free to give it a try, but I think you need a modifier key (e.g., control, meta, command, etc.) to trigger a shortcut vs. a normal keypress event.

The draw tool grabs key presses to change bond order (1, 2, 3), element, etc.

By using the Qt::Key_1 way of doing things I can get it working. It takes precedence over the key capture by the QComboBoxes and doesn’t seem to cause any issues.

This does mean that using 0/1/2/3 to select bond orders no longer works. However, I think this is fine and that the toolbar should be prioritized as it applies across all tools, not just one, and I suspect selecting bond orders like this is very rarely used…

I personally make double bonds either by letting the default “automatic” bond order setting do its thing, or by clicking on the bond after I’ve created it. Obviously that’s highly anecdotal, but I suspect the vast majority of other users also do the same, because this is similar to how we are used to doing it in ChemDraw. And when adding conjugated systems, you tend to want to draw the skeleton first and add double bonding afterwards once you can see where it should go – just like when drawing structures with pen and paper. Doing double bonds post-creation also requires fewer button presses overall.

So I think it would be even fine to not have any keyboard shortcut for the bond order dropdown, but if desired by people I’m sure we could also come up with a different appropriate way to select bond orders via the keyboard, maybe with +/-

@matterhorn103 I agree the suggested 10 degrees per increment of rotation is a bit coarse, and better substituted by steps of 1 degree – for a greater sweep, one either keeps the corresponding key pressed, or uses a multiplier (e.g., 30j for 30 times a 1 degree rotation around the axis tied to j).

Translations by 1 A/step possibly are fine enough to e.g., i) adjust fragment’s relative position, ii) manually join the fragments, iii) optimize the geometry of the new ensemble. I then could imagine to issue a command like 2H to translate a fragment for 2 A to the left.

Oh, I actually liked your suggestion of 10° and thought that if anything it should be larger, maybe 15°. On the basis that it then provides a nice way to get a defined rotation quickly and if e.g. a round 90° rotation is required you can just count the steps, which would be impossible with 1° steps.

Sorry, I disagree. The Control+1 / 2 … choice has been in Avogadro 1, and the individual numbers match ChemDraw for changing bond orders.

Moreover, it keeps interface consistency. Let’s take the case of rotating the camera. Notice that typing keys affects the view / scene, not the interface itself. To do access menu items (or toolbars) you need the control key.

Translating / rotating the scene or fragment were in Avogadro v1 - I haven’t had the time to check the current status, but that’s fine.

I’m not going to merge changes to the toolbar icons. There are already shortcuts and there’s good reason for the current version. (Although I noticed that Control-0 doesn’t change to the 10th icon.)

Ok that’s fine, just ignore the PR then. I got the wrong impression from your vote that you liked the idea, sorry.

Just to note that as far as ChemDraw goes though, the behaviour is already different to Avogadro; in ChemDraw, pressing the number keys either changes the order of the bond the mouse is over, or it adds a fragment (2 = acyl for example), depending on what the highlighted portion of the molecule is. It never switches between the single and multiple bond tools i.e. pressing 2 never means the next bond will be a double bond.

For the large 90 degree increment of rotation of a structure, I wouldn’t mind to press multiple keys with the left hand, and a single on the right one. Ctrl + Shift + Alt and e.g. arrow left, for instance if this combination isn’t yet assigned to an other operation and if (if assigned) it eventually were documented.

BTW, the arrow keys, etc should have worked for rotations, etc. It’s handled by the navigator tool as the default tool. Except there was a bug, which will be shortly fixed.

The default is to rotate 5° with arrow keys, H-J-K-L, but the code is pretty easy to tweak in Navigator::keyPressEvent()

You can also translate the camera with the control modifier, or use the shift modifier to change the rotation axis.

1 Like