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. showDialog and dismissDialog behave strangely when changing orientation

Hi
I am using the showDialog and dismissDialog methods to show progress
dialogs in my app. Moved from creating the dialog and calling show()
on it to using this in order to save state when changing orientation.
But when I change the orientation from portrait->landscape->portrait,
the dismissDialog method call no longer dismisses the dialog. The
dialog stay there all the time and I need to press the back button for
it to disappear.
To overcome this issue, I tried adding a removeDialog in onDestroy so
that the dialog is not created/displayed twice and before orientation
change, the dialog is removed. Tried adding log statements and this is
what happens
05-21 12:35:14.064: DEBUG/MyClass(193): *************callingShowDialog
05-21 12:35:14.064: DEBUG/MyClass(193): *************onCreareDialog

05-21 12:35:15.385: DEBUG/MyClass(193):
*************onSaveInstanceState
05-21 12:35:15.415: DEBUG/MyClass(193): *************onDestroy

05-21 12:35:15.585: DEBUG/MyClass(193): *************callingShowDialog
05-21 12:35:15.585: DEBUG/MyClass(193): *************onCreareDialog
05-21 12:35:15.715: DEBUG/MyClass(193): *************onCreareDialog
05-21 12:35:17.214: DEBUG/MyClass(193):
*************onSaveInstanceState
05-21 12:35:17.214: DEBUG/MyClass(193): *************onDestroy

05-21 12:35:17.275: ERROR/WindowManager(193):
android.view.WindowLeaked: Activity com.android.MyClass has leaked
window com.android.internal.policy.impl.phonewindow$decorv...@43362088
that was originally added here
Some error statements....
05-21 12:35:17.395: DEBUG/MyClass(193): *************callingShowDialog
05-21 12:35:17.395: DEBUG/MyClass(193): *************onCreareDialog
05-21 12:35:17.475: DEBUG/MyClass(193): *************onCreareDialog

Initially when the activity is displayed, the onCreateDialog is called
once and on changing the orientation, onSaveInstanceState and
onDestroy are called.
But after that, onCreateDialog is called twice (once by a call to
showDialog which I make, but why the 2nd time?) and this happens every
time I change the orientation hence forth.
Any idea why that happens?
Thanks
--~--~---------~--~----~------------~-------~--~----~

2. two questions about MediaPlayer

hi all,


I was very confused for MediaPlayer,
follow the audio supporting formate from:
http://developer.android.com/guide/appendix/media-formats.html

i success in mp3 formate,
but failure in wav and 3gp formate..

i can't figure out why i can't?

the other question is the error message from adb logcat,

E/MediaPlayer(  729): error (1, -1)
E/MediaPlayer(  729): Error (1,-1)


can somebody tell me what's the "(1,-1)" means???

i try my best for several methods and audio/video support formate,
but still failuere,
and always get the error message..


can somebody help me ?

thanks!
--~--~---------~--~----~------------~-------~--~----~

3. Could not find class com.google.gdata.data.calendar.CalendarEventFeed

4. How to implement multi-windows in android?

5. how can I control the decoder class in OMX

6. Programmatically prevent Toast from appearing?

7. work on bluetooth api