为什么单击拖动手柄不偷掉文本重点是什么? [英] Why does clicking a drag handle NOT steal away text focus?

查看:240
本文介绍了为什么单击拖动手柄不偷掉文本重点是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些文字的div在 http://jsfiddle.net/MuCeD/2/。在它被突出显示在div如果我双击单词样品,如果我再点击其他地方的网页上的文字变得无法凸显 - 除了的,如果我点击蓝色的拖动手柄第二个盒子。然后,取样保持突出显示。

I have a div with some text at http://jsfiddle.net/MuCeD/2/. If I double-click the word "sample" in the div it becomes highlighted and if I then click anywhere else on the page the text becomes un-highlighted - except if I click on the blue drag handle of the second box. Then "sampled" remains highlighted.

如果您取下手柄规格如下,

If you remove the handle specification, as below,

$('#box').draggable();

这样你就可以从左边框中任意位置拖动,那么您可以在该框中单击不失文本焦点的任何地方。

so you can drag from anywhere on the left box, then you can click anywhere in that box without losing the text focus.

有谁知道这是怎么回事呢?什么是拖动手柄做偷焦点保留?

Does anyone understand what's going on here? What does the drag handle do to keep from stealing the focus?

感谢

推荐答案

jQuery UI的可拖动取消其鼠标按下事件。这就是为什么它不接收焦点,因此不偷其它元素的焦点。您可以使用拖动上下文之外下面的例子。

The jQuery UI draggable cancels its mousedown event. This is why it doesn't receive focus and thus doesn't steal other elements' focus. You can use the following example outside of the draggable context.

HTML

<a href="#">Some link</a>
<a class="not-focusable" href="#">No focus</a>

JavaScript的:

JavaScript:

$('.not-focusable').mousedown(function (event) {
    return false;
});

的jsfiddle

这篇关于为什么单击拖动手柄不偷掉文本重点是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆