andfanilo/streamlit-drawable-canvas

Feature/Query on stop deleting

hafiidz opened this issue · 0 comments

Hi, first of all, thank you for the great library

Use case

I want to use the canvas rect (initiated via initial drawing) object as data info for cropping application, within transform mode.
I am however having a problem with UX when user mistakenly delete the box by double click during dragging action.

Options?

Is there anyway I can:

  • disable double clicking within the canvas
  • OR have a way to keep at least one rect inside the canvas_result.json_data
  • OR auto re-add one rect once empty

in the same topic, is there a way to manually inject the shape into the object besides initial drawing?

I know there seems to be multiple questions, but there are all for this single use case. Either one will do.

Research done so far

  • I have searched and found streamlit_cropper library, but there is another use case for canvas and thus if possible I wanted to use this library. Also encountered a weird bug with this, might need to raise a bug there as well later.
  • Tried searching for double click disable via JS, but it seems to be a XSS issue due to the iframe
  • Tried searching for delete in issues list & streamlit forum but couldn't find relevant portion
  • Might need to find a way to fork and use local version rather than PIP, but I really hope it won't come to that. Do give me a feedback if this is indeed the way to go.
  • One intermediate solution is just to include big notice for user to click undo if no more rect present on the page.