3

I'm creating a simple javacript window manager with basic functions like all windows managers(moving, resizing, depth-sorting, etc).

I'm using events like mousedown and mouseup to know when to move the window or not. However, sometimes, when I try to move the window, chrome hooks up on it and drags the "content"(I don't know the right word to use here, just imagine you're dragging an image from the browser to your desktop), like the image below.

ss
(My cursor is there, it just doesn't appear on the screenshot).

Whenever this happens, chrome just simply don't trigger the mouseup event when i release the button, so the windows keeps following the mouse until I click again.

Is there any workaround to make chrome don't activate its dragging system?

Thanks.

Community
  • 1
  • 1
Leonardo Arroyo
  • 573
  • 6
  • 16
  • Does this answer your question? [Disable Drag and Drop on HTML elements?](https://stackoverflow.com/questions/704564/disable-drag-and-drop-on-html-elements) – gunr2171 Aug 12 '23 at 17:37

1 Answers1

2

Try adding the draggable="false" attribute to relevant elements. By default <img> and <a> elements can be dragged, as can selected text (not much you can do about that one).

Alternatively, try adding ondragstart="return false;" to the document.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
  • `draggable="false"` didn't work. `ondragstart="return false;"` did the trick, although the cursor still changes to a selection pointer. I was able to solve it with a `e.preventDefault()` on the mousedown event, it doesn't changes the cursor and neither attributes are needed. – Leonardo Arroyo Jul 11 '13 at 23:46