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的一部分。