react-diagrams icon indicating copy to clipboard operation
react-diagrams copied to clipboard

Version 6 CanvasWidget deleteKeys alternative

Open mathiasbaldissera opened this issue 7 years ago • 2 comments

Hello,

In version 5, the DiagramWidget have the deleteKeys prop, but at version 6, itsn't avaible, whats the alternative to do this? (i want to use only "Delete" to remove elements)

mathiasbaldissera avatar Aug 29 '19 19:08 mathiasbaldissera

I was facing the same issue with Version 6. From what I have seen you can do the following options:

  1. Delete the DeleteItemsAction completely (or temporarily) from the eventBus (see #334 )
  2. Lock the model with BaseModel.setLocked(true). I used this one for my nodes because they have multiple input fields. Everytime onFocus for the Textfield the corresponding model gets locked and onBlur it gets unlocked. This allows me to delete in the input field with [backspace] or [del] without deleting the node. Furthermore it blocks the node from dragging if I select something in the textfield.

christianbuehlmeyer avatar Sep 12 '19 22:09 christianbuehlmeyer

Thanks, @christianbuehlmeyer . The option 2 looks great, I didn't remeber the setLocked function. In the first option, I need to modify the library source code, right? (the library don't export the DeleteItemsAction and the Action array are protected)

mathiasbaldissera avatar Sep 12 '19 23:09 mathiasbaldissera