Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何在WebView中捕获鼠标下降事件?_Objective C_Macos_Cocoa_Webview_Webkit - Fatal编程技术网

Objective c 如何在WebView中捕获鼠标下降事件?

Objective c 如何在WebView中捕获鼠标下降事件?,objective-c,macos,cocoa,webview,webkit,Objective C,Macos,Cocoa,Webview,Webkit,我想处理WebView中的mouseDown事件。我对WebView进行了子类化,实现了mouseDown,我知道mouseDown被重定向到WebHTMLView <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title></title> <script type="text/

我想处理
WebView
中的
mouseDown
事件。我对
WebView
进行了子类化,实现了
mouseDown
,我知道
mouseDown
被重定向到
WebHTMLView

 <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title></title>
    <script type="text/javascript">
    function SetValues()
    {
        var s = 'X=' + window.event.clientX +  ' Y=' + window.event.clientY ;
        document.getElementById('divCoord').innerText = s;

    }  
</script>
</head>
<body id="bodyTag" onclick=SetValues()>
<div id="divCoord"></div>
</body>
</html>
我已经浏览了以下链接

从上面的链接我知道,我们可以将mouseDownEvent重定向到Objective-C,但我没有找到任何解决方案。我可以有任何指针或示例javascript来实现相同的功能吗

我在
webview
子类中尝试了hitTest方法

- (NSView*)hitTest:(NSPoint)aPoint

是否可以用上述方法识别鼠标下降

您也可以使用onTouchStart事件。请参阅此

或者使用以下命令:-

$('button').bind( "touchstart", function(){alert('hey'} );
touchstart相当于mouseDown

另一个解决方案是将元素的光标设置为指针,并使用jQuery live和click事件。在CSS中设置它。(光标:指针)

在javaScript中,您可以使用:-

node.ontouchmove = function(e){
  if(e.touches.length == 1){ // Only deal with one finger
    var touch = e.touches[0]; // Get the information for finger #1
    var node = touch.target; // Find the node the drag started from
    node.style.position = "absolute";
    node.style.left = touch.pageX + "px";
    node.style.top = touch.pageY + "px";
  }
}

有关更多详细信息,请参阅


有关Mac OSx,请参见

您可以使用onTouchStart事件进行相同的操作。请参阅此

或者使用以下命令:-

$('button').bind( "touchstart", function(){alert('hey'} );
touchstart相当于mouseDown

另一个解决方案是将元素的光标设置为指针,并使用jQuery live和click事件。在CSS中设置它。(光标:指针)

在javaScript中,您可以使用:-

node.ontouchmove = function(e){
  if(e.touches.length == 1){ // Only deal with one finger
    var touch = e.touches[0]; // Get the information for finger #1
    var node = touch.target; // Find the node the drag started from
    node.style.position = "absolute";
    node.style.left = touch.pageX + "px";
    node.style.top = touch.pageY + "px";
  }
}

有关更多详细信息,请参阅


对于Mac OSx,请参见

我使用以下HTML和JavaScript捕获鼠标事件,并在
网络视图
中显示鼠标单击的位置

 <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title></title>
    <script type="text/javascript">
    function SetValues()
    {
        var s = 'X=' + window.event.clientX +  ' Y=' + window.event.clientY ;
        document.getElementById('divCoord').innerText = s;

    }  
</script>
</head>
<body id="bodyTag" onclick=SetValues()>
<div id="divCoord"></div>
</body>
</html>

函数SetValues()
{
变量s='X='+window.event.clientX+'Y='+window.event.clientY;
document.getElementById('divCoord')。innerText=s;
}  

我使用以下HTML和JavaScript捕获鼠标事件,并在
网络视图中显示鼠标单击的位置

 <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title></title>
    <script type="text/javascript">
    function SetValues()
    {
        var s = 'X=' + window.event.clientX +  ' Y=' + window.event.clientY ;
        document.getElementById('divCoord').innerText = s;

    }  
</script>
</head>
<body id="bodyTag" onclick=SetValues()>
<div id="divCoord"></div>
</body>
</html>

函数SetValues()
{
变量s='X='+window.event.clientX+'Y='+window.event.clientY;
document.getElementById('divCoord')。innerText=s;
}  

corona zorro:这不是iPhone。你对同一款Cocoa有什么建议吗?Cocoa Touch是一个UI框架,用于构建运行在苹果公司的iPhone、iPod Touch和iPad上的软件程序。因此,它也适用于这些,它只是iPhone的一部分。科罗纳·佐罗:它不是iPhone。你对同样的可可有什么建议吗?Cocoa Touch是一个UI框架,用于构建运行在苹果公司的iPhone、iPod Touch和iPad上的软件程序。因此,它也可以在这些设备上运行,它只是iPhone的一部分。