nurpax / petmate

PETSCII editor with Electron/React/Redux
MIT License
181 stars 14 forks source link

enable drag reordering of screen tabs #85

Closed nurpax closed 5 years ago

nurpax commented 5 years ago

petmate-drag-screens-bug

I implemented this but hit an annoying problem with canvas elements. The react-sortable-hoc library that I use for drag sorting clones the element it's moving. Unfortunately the <canvas> element cannot be cloned with Node.cloneNode() so that it wouldn't lose it's painted contents. So would need to turn the painted canvas into another canvas by cloning the painting into a canvas img. There are examples of how to do this (e.g., https://gist.github.com/adouglas/5266778) but this would require modifying the react-sortable-hoc library.

nurpax commented 5 years ago

Fixed react-sortable-hoc and sent a PR. Dragging works now.

Only problem is that on macOS, if I right-click using ctrl+touchpad, a left button down event goes to the drag control and dragging starts. There doesn't seem to be any way to detect this anywhere. So I'm going to recommend people to not use right-click with ctrl and instead configure this from touchpad settings.