DynaTree 在左键单击后右键单击时有两个突出显示的节点
我的问题是,每当我左键单击一个动态树节点,然后右键单击另一个动态树节点以显示我的上下文菜单时,左键单击的节点仍以蓝色突出显示,因此我最终会得到两个蓝色节点。如果我右键单击连续的节点,突出显示将正常工作,但左键单击的节点仍保持突出显示。
左键单击处理会清除 mouseup 上的前一个节点。我启动上下文菜单处理,通过
document.oncontextmenu=contextMenu
它也可以在鼠标松开时调用。
我尝试捕获右键 mouseup 事件并使上下文菜单节点处于活动状态,认为这会改变左键单击节点的状态,但事实并非如此。
$("#tree").mouseup(function(e){
if(e.button == 2){
e.target.setActive();// right mouse up
}
});
当右键单击另一个节点时,如何使最后一个左键单击的节点取消突出显示?同时突出显示两个节点看起来不太正确。我注意到,当右键单击另一个节点时,dynatree 上下文菜单演示不会取消突出显示先前左键单击的节点,这是设计使然吗?你能绕过它吗?
谢谢, 铝
My problem is whenever I left click a dynatree node then right click another dynatree node to display my context menu the node which was left clicked remains highlighted in blue so I end up with two nodes in blue. If I then right click successive nodes the highlighting works correctly but the left clicked node remains highlighted.
The left click processing clears the previous node on mouseup. I initiate context menu processing via
document.oncontextmenu=contextMenu
which is also called on mouse up.
I have tried to capture the right button mouseup event and make the context menu node active thinking that would change the state of the left clickked node but not so.
$("#tree").mouseup(function(e){
if(e.button == 2){
e.target.setActive();// right mouse up
}
});
How should I get the last left clicked node to unhighlight when another node is right clicked ? It does not look right to have two nodes highlighted at once. I have noticed the dynatree context menu demo does not unhighlight the previously left clicked node when another node is right clicked so is this by design ?? Can you get around it ?
Thanks,
Al
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我在显示器周围单击时发现的另一个更改
而不是
使用
这纠正了单击非 A 元素时重新出现旧突出显示问题的问题。
铝
One more change I found while clicking around the display
Instead of
use
This corrects a issue where the old highlighting problem reappears of a non A element is clicked.
Al
我知道这已经很旧了,但我刚刚遇到了同样的问题。当手动尝试管理节点上的 'dynatree-active' 类以强制突出显示时,我遇到了选择多个节点的问题。通过使用左键单击和右键单击,dynatree 管理所有选择和取消选择活动节点。
我在这个问题上挣扎了一段时间,我希望它能为某人减轻一些痛苦。
I know this is old, but I just ran into the same problem. When manually trying to manage
'dynatree-active'
classes on nodes to force highlighting, I was having issues with multiple nodes being selected. By using a left click along with the right click, dynatree managed all of the selecting and deselecting active nodes.I struggled with this one for a bit, I hope it can save someone some pain.
我需要添加一个添加到 jquery.dynatree.js 的简短方法才能使其工作。
I need to add a short method I added to jquery.dynatree.js to make it work.
好的,这可以
在我创建动态树后在 myfile.js 中添加:
摘要:
通过跟踪要左键单击的最后一个元素并通过 getDtNodeFromElement2 公开 dynatree getDtNodeFromElement 方法,每当第一次右键单击节点时,就可以调用最后一个左键单击的节点上的 deactivate 方法。这消除了树节点的同时突出显示。
OK this works
In my myfile.js after I create the dynatree I added:
Summary:
By keeping track of the last element to be left clicked and exposing the dynatree getDtNodeFromElement method through getDtNodeFromElement2 it is possible to call the deactivate method on the last left clicked node whenever the first right click of a node occurs. This eliminates simultaneous highlighting of tree nodes.