How to use mouse event(onmousemove) in Android WebView?

by seri » Fri, 06 Mar 2009 05:19:39 GMT


Sponsored Links
 On iPhone, This is donw with addtional events
(ontouchmove,ontouchstart,ontouchend)
I know that these are only available in iPhone Safari.

Is There any way to control by touch event(onmousemove)?
How to use mouse event in WebView or Browser ?

-----------------------------------------------------------------------------------------------------
<html>
<head>
<title> Event </title>
<style>
.drag { position: relative; cursor:move }
</style>
<script language="JavaScript">
<!--
var bdown = false;
var x, y;
var sElem;

function mdown() {
 if(event.srcElement.className == "drag") {
  bdown = true;
  sElem = event.srcElement;
  x = event.clientX;
  y = event.clientY;
 }
}
function mup() {
 bdown = false;
}
function moveimg() {

 if(bdown)
 {

  var distX = event.clientX - x;
  var distY = event.clientY - y;
  sElem.style.pixelLeft += distX;
  sElem.style.pixelTop += distY;
  x = event.clientX;
  y = event.clientY;

 return false;
 }
}

document.onmousedown  = mdown;
document.onmouseup  = mup;
document.onmousemove  = moveimg;

//-->
</script>
</head>

<body>


<img src=" http://farm1.static.flickr.com/52/157145833_958fb267a2.jpg? 
v=0" class="drag">

</body>
</html>


--~--~---------~--~----~------------~-------~--~----~



How to use mouse event(onmousemove) in Android WebView?

by seri » Fri, 06 Mar 2009 05:19:44 GMT


 On iPhone, This is done with new additional events
(ontouchmove,ontouchstart,ontouchstart).
I know that these are not available in Android.

How can I use mouse event(onmousemove) in Android WebView or Browser?

-----------------------------------------------------------------------------------------
<html>
<head>
<title> New Document </title>
<style>
.drag { position: relative; cursor:move }
</style>
<script language="JavaScript">
<!--
var bdown = false;
var x, y;
var sElem;

function mdown() {
 if(event.srcElement.className == "drag") {
  bdown = true;
  sElem = event.srcElement;
  x = event.clientX;
  y = event.clientY;
 }
}
function mup() {
 bdown = false;
}
function moveimg() {

 if(bdown)
 {

  var distX = event.clientX - x;
  var distY = event.clientY - y;
  sElem.style.pixelLeft += distX;
  sElem.style.pixelTop += distY;
  x = event.clientX;
  y = event.clientY;

 return false;
 }
}



document.onmousedown  = mdown;
document.onmouseup  = mup;
document.onmousemove  = moveimg;

//-->
</script>
</head>

<body>


<img src=" http://farm1.static.flickr.com/52/157145833_958fb267a2.jpg? 
v=0" class="drag">

</body>
</html>


--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Proper Intent for Launching Gallery?

What is the proper Intent to launch the gallery or gallery picker?

I'm using the following code, and a lot of users are complaining of a
force close error. It works just fine on my stock G1, but with the new
phones out it seems to be an issue.


Intent intent = new Intent();
intent.setClassName("com.android.camera",
        "com.android.camera.GalleryPicker");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);

What is the proper intent?

Further ...
My app stores photos on the sd card (photos taken from the camera and
stored using the Media Scanner) ... Is it possible to launch the
gallery into that specific gallery instead of the gallery picker? Or
is the gallery picker the only option?

Thanks in advance.


--~--~---------~--~----~------------~-------~--~----~

2. InvokeZoomPicker

How can a webview be created with the ZoomPicker enabled and the
webpage zoomed out?

I have the following code that doesn't work:

                WebView mywebview = getWebView() ;
                mywebview.setWebViewClient(getWebViewClient());
                mywebview.getSettings().setJavaScriptEnabled(true);
                mywebview.getSettings().setLoadsImagesAutomatically(true);
                mywebview.getSettings().setSupportZoom(true) ;
                mywebview.getSettings().setBuiltInZoomControls(true) ;
                mywebview.getSettings().setUseWideViewPort(true) ;
                mywebview.loadUrl("http://www.usnaviguide.com/v3maps/test.htm");
                mywebview.invokeZoomPicker() ;

It does allow the ZoomPicker if the page is moved around.

What am I doing wrong?

Thanks in advance.

-John Coryat
--~--~---------~--~----~------------~-------~--~----~

3. The server does not accept apks signed with the debug certificate.

4. Support for Arabic?

5. Urgent: ListView icon problem

6. Quattrowireless - monetizing your app

7. The server does not accept apks signed with the debug certificate.