简体   繁体   English

在Chrome中单击并拖动光标

[英]Click and Drag Cursor in Chrome

I am working on a web app and I need to override some of the default cursors. 我正在开发一个Web应用程序,我需要覆盖一些默认游标。

In chrome when I click and then drag it ALWAYS changes the cursor to text selection. 在Chrome中,当我单击然后拖动它时,总是将光标更改为文本选择。 I can not seem to find any way to override this. 我似乎无法找到任何方法来覆盖它。

I am using jquery, and the usual 我正在使用jquery,和平常一样

$(document).css('cursor','default');

Does not work. 不行。

With chrome it seems that it brings it up not on the click, but on the mouse move. 使用chrome似乎它不是点击,而是鼠标移动。 So I have even attempted to do 所以我甚至试图这样做

$(document).mousemove(function(){
    $(document).css('cursor','default');
});

And that doesn't seem to work either. 这似乎也不起作用。

I do not have this issue in firefox though. 我在Firefox中没有这个问题。

Try turning off any text selection while drag and dropping as per chrome sets cursor to text while dragging, why? 尝试关闭任何文本选择,同时拖动按照chrome将光标设置为拖动时的文本,为什么? .

document.onselectstart = function(){ return false; }

It displays the text cursor because you are selecting Text while dragging (although you don't want to, but try just holding the mouse button, and moving it around the screen). 它显示文本光标,因为您在拖动时选择文本(虽然您不想,但只需按住鼠标按钮,然后在屏幕上移动它)。 To disable this, I would suggest you to use something like this 要禁用此,我建议你使用类似这样

You may need to change the code in the link to disable all text, not just text within tag label. 您可能需要更改链接中的代码以禁用所有文本,而不仅仅是标记标签中的文本。 To disable the text while dragging, and when you release the mouse button to undo the changes made by disabling the text. 在拖动时禁用文本,以及释放鼠标按钮以撤消通过禁用文本所做的更改时。

As soon as the text selection is disabled, Chrome should have no reason to display other cursors. 禁用文本选择后,Chrome应该没有理由显示其他游标。

Hope this helps. 希望这可以帮助。

EDIT: I am new to stackoverflow, and did not know a real tag would not be displayed. 编辑:我是stackoverflow的新手,并不知道不会显示真正的标签。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM