Moving objects with arrowkeys

Hello

In the post Overriding draggingTool.moveParts - #6 by Hochware I stated that my diagram has grouping functionality and I am overriding computeEffectiveCollection in order to change the set of objects that are affected by “moveParts”. However, this does not work for moving objects with the arrow keys. I did not yet find any way to override this function. Any suggestions?

Best regards
Martin

By default the arrow keys do not move anything – they scroll the viewport.

You must have customized the behavior of those keys. That is commonly done with DrawCommandHandler | GoJS API.

Yes, sorry I did not mention that. I did set “arrowKeyBehaviour” to “move”. I also set “commandHandler” in the diagram to “new DrawCommandHandler()”. Then I defined this:

I really do not know at all how this thing works…I do not know how to get the pressed key directly(of course there are other, ugly ways) and I get an error too:


The “computeEffectiveCollection” is working as intended when dragging an element with the mouse

You’ll need to change the DrawCommandHandler _arrowKeyMove method to do what you want. Instead of iterating over the Diagram.selection, iterate over the diagram.toolManager.draggingTool.computeEffectiveCollection(diagram.selection).iteratorKeys.

Thank you, that worked.
This is my _arrowKeyMove:

set=_.extendSelectionByGroups() works the following way:

I encourage everyone reading this to use the grouping functionality provided by GoJS, all those problems (there are multiple posts, as well as other little problems I was able to solve on my own) emerged because I did not use this. Right now I am in the process of implementing those groups and it already solved some issues I was not able to solve before