Lock mouse cursor while dragging in Chrome

This is not the same question as everyone else. I already prevent Chrome from entering text selection mode when dragging and dropping. (Edit: I just want to lock the icon / appearance, and not restrict the location or movement, and only between mousedown and mouseup). I would like to avoid: Chrome changes the cursor when dragging to everything that is under the cursor (i.e. i-beam while input control over the text, manual work on the hyperlink, etc.).

IE and FireFox / Moz support element.setCapture (), which I call in the mousedown event, which "blocks" these browsers for the element, so that the mouse cursor remains at all that the cursor of this element ... is very nice. Chrome does not support this feature or anything like that that I know of.

By observing the mousemove and mouseup events on the document object, and not on the element that was clicked, I can get more setCapture () behavior to track mouse events that occur outside the element and even outside the browser window. However, I was left with another problem, the mouse cursor has changed in Chrome.

+6
source share
2 answers

I usually place an element above everything else with the intended cursor on the mouse and delete it with the mouse. Far from the purest approach, but it works for me.

0
source

I believe that you are looking for a direction indicator lock API , a recently introduced way for users to control a user input device (when enabled). A great use case is games.

Without a secure and supported API, allowing sites to take user input controls will be quite disastrous (for example, with mouse clicks and forced download of malware), so if you want to “lock” the cursor, then this will most likely be your only option.

+3
source

All Articles