我想添加一个上下文菜单项,以允许我重复resharper的最后一次测试运行,类似于测试driven.net添加的那个.这可能吗?
我已经想出了如何使用注册表将菜单项添加到Windows资源管理器的右键单击上下文菜单中.我目前已将其设置为在单击菜单项时启动我的应用程序.
但是,我想知道是否有办法知道右键单击了哪个文件.我以为它会作为命令行参数发送到已启动的程序,但事实并非如此.有任何想法吗?
当右键单击NSWindow时,有没有办法显示菜单?
我在javascript中为表格开发了右键单击上下文菜单。上下文菜单的位置在表格每一行的光标下方。表格的最后一行在页面的末尾,现在右键单击上下文的行菜单正在下降,但应该显示在光标上。
function ContextShow(event) {
event = event || window.event;
var m = getMousePosition(event);
var s = getScrollPosition(event);
var client_height = document.body.clientHeight;
var display_context = document.getElementById('context_menu');
if(replaceContext){
display_context.style.display = "block";
display_context.style.left = m.x + s.x + "px";
display_context.style.top = m.y + s.y + "px";
replaceContext = false;
}}
function getMousePosition (e){
e = e || window.event;
var position = {
'x' : e.clientX,
'y' : e.clientY
}
return position;}
function getScrollPosition(){
var x = 0;
var y = 0;
if( typeof( …Run Code Online (Sandbox Code Playgroud) 我想当有人用鼠标右键单击某个区域时打开一个弹出窗口。我现在正在使用这个:
$("#popup").bind('mousedown', function(e) {
var w;
if(e.which==3) {
w=window.open('link','_blank','options');
} else {
return false;
}
if(w!=null){
w.focus();
}
event.preventDefault();
});
Run Code Online (Sandbox Code Playgroud)
当与 Firefox 一起使用时(尽管尚未在其他浏览器上进行测试),弹出窗口被阻止。我注意到“点击”事件根本不起作用。
有什么方法可以在右键单击某个内容时打开弹出窗口而不被浏览器阻止吗?
问题是如果按下鼠标右键,我如何防止刷子事件(brushstart,brush和brushend)被触发.换句话说,我希望d3画笔仅在按下鼠标左键或鼠标中键时才会动作.我既没有在这里找到这个问题的直接答案,也没有通过Google搜索来找到答案.
HandleClick 似乎只处理左键单击,但看起来我可以使用onmouseup和MouseEventArgs.Button属性来检测右键单击。
问题是出现了典型的浏览器提供的上下文菜单。有没有办法防止这种情况?我在 Blazor 中没有看到类似 preventDefault() 的内容。
更新:显然我们可以做,@onmouseup:preventDefault但上下文菜单仍然显示
如何检测右键单击的对象或ID或用户?我正在使用onContextMenu来触发一个函数,但我不知道如何检测目标.
我正在使用Kineticjs,我正在定义这样的rect事件
this.rect.on('click tap', function(){
foo();
});
Run Code Online (Sandbox Code Playgroud)
当我左键单击时,也会在右键单击时触发该事件.如何通过右键单击来避免触发此事件?(我无法在页面中禁用右键单击,因为如果我右键单击rect,我想打开上下文菜单)
谢谢
我注意到,在Firefox上单击鼠标右键会触发addEventListener。
我在更多浏览器和更多操作系统(IE 11-10-9,Safari,Chrome)上尝试了此代码,并通过右键单击鼠标,仅在Firefox上始终打印console.log消息。
<div id="one-div" style="height:400px;width:500px;background-color:#000;"> click me </div>
<script>
function cb(event, from){
// if click is fired on <div> with:
// left click, both EventListener will be printed.
// right click, only the 'document' one will be printed.
event.preventDefault();
console.log(event + ' from: ' + from );
}
document.addEventListener('click', function(e){
cb(e,'document');
}, false);
document.getElementById("one-div").addEventListener('click', function(e){
cb(e,'one-div');
}, false);
</script>
Run Code Online (Sandbox Code Playgroud)
而且我还注意到,当将点击触发到div中时,它仅触发document.addEventListener。我搜索了Firefox changelog,但没有相关新闻。
谁能解释这种行为?谢谢!
right-click ×10
contextmenu ×6
javascript ×4
jquery ×2
automation ×1
blazor ×1
cocoa ×1
d3.js ×1
dhtml ×1
events ×1
firefox ×1
kineticjs ×1
mouse ×1
mouseevent ×1
objective-c ×1
popup ×1
rect ×1
registry ×1
resharper ×1
window.open ×1
windows ×1