控制单击或移动单击多个项目并拖动它们 [英] Control click or shift click multiple items and drag them

查看:128
本文介绍了控制单击或移动单击多个项目并拖动它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在看这些论坛,尝试了很多插件,即:jquery.hotkeys.js和 http://thechriswalker.net/select-drag/ 示例在这里完成了一个优秀的插件,它只是比我想要的更复杂。



我已经在列表2中排序了一个拖放情况,感谢CoolEsh在之前的惊人的帮助..



所以现在我需要一个控制点击来选择多个并拖动它。但是我不想加载一些标记和jQuery。但是我也不想像我所说的那样使用一个复杂的插件。



任何想法?

解决方案

事件 e 内置了可以访问的变量检查是否已经按下控件 alt shift 。看看 here


$ b $($ e code $ $''''''''''''''''''' $ b if(e.altKey)alert('altressed');
});

如果你知道控件也被按下,你可以添加一个类 selectedItem 或类似的东西。在mouseup事件中,您可以检查是否按下该键,如果没有,则删除 selectedItem 类。而不只是添加一个可拖动到 $('。selectedItem'),你几乎在那里。


I have been looking on these forums all day and tried lots of plug-ins namely : jquery.hotkeys.js and the http://thechriswalker.net/select-drag/ example here complete with an excellent plug-in, it's just a lot more complex than what I think I'm looking for.

I already have a drag and drop situation with sortable in list 2 thanks for to CoolEsh for his amazing help earlier on.. connecting sortable lists disallowing sorting on the first list jQuery

So now I'm needing a control click to select more than one and drag it across. But I don't want loads of mark-up and jQuery. but I also don't want to use a complex plug-in like the ones I mentioned.

Any ideas?

解决方案

The event e has built in variables that you can access for checking if control, alt or shift have been pressed. Have a look here.

$('#selectableitems p').click(function(e) {
    if(e.ctrlKey) alert('control pressed');
    if(e.altKey) alert('alt pressed');
});

If you know that control is also pressed, you could add a class selectedItem or something like that. On a mouseup event you could check if the key is pressed and delete the selectedItem class if not. Than just add a draggable to the $('.selectedItem') and you're pretty much there.

这篇关于控制单击或移动单击多个项目并拖动它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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