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. Advice needed for app navigation methods

Hello folks,

I'm porting an iPhone app to the Android OS.  The iPhone app is based
on the iPhone navigation controller template, the principal component
of this being the large navigation bar at the top of the screen.  For
those who don't know the iPhone SDK, the navigation bar tracks the
user's location in the hierarchy of information presented by the
application, and establishes a "stack" of views.  When I click on an
item on the current view I can push a new view onto the stack, this
automatically places a back button on the navigation bar that would
pop the current view off the stack and bring my back to the previous
view.

I don't see an equivalent widget or API to this in the Android SDK, so
I'll have to implement something similar on my own if I want to
maintain the same style of navigation.  What I am trying to figure out
is how I should manage control of the stack.  Should I put back
buttons on a navigation bar so the user can stick purely to the
touchscreen?  Or should I make use of the back button on android
phones and leave more space for the title of the current screen on the
bar at the top?

Can anyone comment on this?  Is it safe to rely on the presence of the
back button for all devices the app may be running on?  Or do some
phones not even have a physical back button?  Any links explaining the
hardware differences between all the android devices would be helpful
here if someone can share.

Thanks!

Robert Hawkey
Stormtap Studios

--

2. APK not visible in market for HTC Tattoo Android Phone ?

The tattoo has a low density screen if I remember correctly. Your application 
would have to support low density screens explicitly for it to show up in the 
market.

Regards
S





> 

3. The method versionName() is undefined for the type PackageInfo

4. NexusOne newbie and disappointed... here is why...

5. NexusOne newbie and disappointed... here is why...

6. AccountManager sync policy

7. Finally Hit a Wall