2012-05-14 4 views
1

WebViewmouseDownイベントを処理したいと思います。 WebViewをサブクラス化し、mouseDownを実装しました。mouseDownWebHTMLViewにリダイレクトされたことがわかりました。WebViewでmouseDownイベントをキャプチャする方法は?

私は次のリンクを行っています。私が知るようになった上記のリンクから

mouseDown: not firing in WebView subclass

、私たちは、Objective-CのにmouseDownEventをリダイレクトすることができますが、私はこのための任意の解決策を見つけることができませんでした。同じポインタを実装するためのポインタやサンプルJavaScriptを用意できますか?

webviewサブクラスでhitTestメソッドを試しました。

- (NSView*)hitTest:(NSPoint)aPoint 

上記の方法でマウスを認識することはできますか?

答えて

0

ため

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"; 
    } 
} 

または

document.addEventListener('touchstart', function(event) { 
    alert(event.touches.length); 
}, false); 

私はもMouseEventをキャプチャすると位置を表示するには、次のHTMLとJavaScriptを使用しましたWebViewのマウスクリックの

<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> 
1

あなたはこのlink to bind events on iphone

またはこれを使用するのと同じ.ReferためonTouchStartイベントを使用することができます -

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

touchstartは別のソリューションは、に要素のカーソルを設定することでmouseDownイベント

に相当します(カーソル:ポインタ)

javaScriptでは、次のように使用できます。 - 詳細は、Mac OSXを参照してくださいThe Linkについてjavascript iPhone Events

を参照してください

+0

コロナゾロ:iPhoneではありません。同じココアのヒントはありますか? – Ram

+0

Cocoa Touchは、Apple Inc.のiPhone、iPod Touch、およびiPad上で動作するソフトウェアプログラムを構築するためのUIフレームワークです。したがって、これはiPhoneの一部でもあります。 –

+1

彼はmac os xを求めています。 – vikingosegundo

関連する問題