Jan Turoň
Jan Turoň

Reputation: 32912

Why mousemove event cripples number input in Chrome?

In Chrome v.25 I use this code to avoid text cursor while dragging HTML element:

document.addEventListener("mousemove",function(e) { e.returnValue = false; });

Every <input type="number"/> is crippled (see jsfiddle)

I already managed to avoid this by setting the false returnValue only while dragging. But what exactly happens here? Is it a bug or some feature?

Upvotes: 1

Views: 111

Answers (1)

Seer
Seer

Reputation: 5237

You can achieve this with CSS, if I understand what you mean correctly...

.no-select {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

Just add that to the elements that you don't want to be selectable.

This does look like rather a string issue, as I wouldn't call pressing up on a number input a mousemove event, but in any case, the issue exists. The CSS may be a more elegant solution.

Check the fiddle here:

http://jsfiddle.net/uP7TH/3/

Upvotes: 1

Related Questions