Disabling modeling && Handtool/Spacebar key binding

Good morning team!
I am working on a Camunda Modeler plugin which should implement an editor (sort of…).
I implemented a DisableModeling feature like the one implemented on bpmn-js-token-simulation module, but I still have one problem:
When I press the space bar, it seems that the handTool module intercepts the input. How can I disable it? I tried to do it on my module using the same ignoreIfModelingDisabled function (as written below), but it does not seem to solve the issue, every time the function interceptor for editorActions receives a trigger from ‘activateHandtool’.
What am I doing wrong?

  ignoreIfModelingDisabled(handTool, 'activateMove');
  ignoreIfModelingDisabled(handTool, 'activateHand');
  ignoreIfModelingDisabled(handTool, 'toggle');

I tried also to add listeners to the keyboard module, without effect.

Hi Ichigo85,

Could you share your work in a CodeSandbox?
It’s difficult to tell what’s not working, only seeing this little bit of code.

1 Like

Hi @azeghers ,
here is an example of my code. I tried also to unbind keyboard (or bind keys to nothing) but it does not seem to work. If you try to press ‘S’ or spacebar on my example, toggling on the button on the right, keybindings still work and intercept functionalities that I want to disable in that case (which is, for instance, I opened the editor, and I don’t want that every key I press is also took from modeler key bindings).
I hope I explained better the issue.
Thank you very much!

Hi Ichigo85,

Thank you for providing the sandbox, and sorry about the delay.
Did you solve your issue?
When I try using it, it seems to work as you intended it to (toggling the button prevents any modeling action).

Hi! Well, with a small hack, yes, I kinda made a small workaround, but I did not disable keyboard bindings completely. I just forced the editor to respond to spacebar.
In my sandbox, if you keep pressing space you still can move the canvas (using the handtool). Modeling was disabled, but not everything, let’s say.
It could be anyway interesting to know how to disable handtool.

When you click on the canvas and move it, it’s not the hand tool that is doing that, but the MoveCanvas module. So you might want to fiddle around with this one.


Thank you @Niklas_Kiefer ! I saw the ‘activateHandTool’ event type and I thought that was it. I’ll have a look!