Newsgroup: it.comp.lang.javascript
Titolo: muovi il mouse setmouseposition?

ciao,
qualcuno mi sa dire come posso posizionare il puntatore del mouse su un 
link da codice, senza il dispositivo?
Ho letto qualcosa su setmouseposition ma non sono riuscito ad usarlo.
Avete una soluzione semplice?
Grazie,
Francesco. 
--
firs...@virgilio.it
Inviato da 
www.mynewsgate.net

 Avete una soluzione semplice?
Spicacente ma non ne conosco, e a dire il vero troverei fastidioso che 
sia un programma a muovermi il puntatore.
Prova ad indicare il problema che vuoi risolvere, forse c'è una 
soluzione più idonea. Quello che puoi fare è settare il focus su 
qualcosa (al caricamento dela pagina o in base a qalche evento)
Ciao

Magari lo ha letto nel manuale di java...
-- 
"That until there is no longer first class
And second class citizens of any nation
Until the colour of a man's skin
Is of no more significance than the colour of his eyes
Me say war"
B.M.
--

L'ho letto in questo sito:
http://www.wildtangent.com/developer/howtos/JSGameTutorial/chapter5/tutori
al_ch5.html
Ma non riesco nemmeno ad implementare l'oggetto "wt".
Spiego il l'esigenza:
ho un pagina html i cui <A> tag eseguono lo swap di un immagine allo 
scatenarsi dell'evento onmouseover, dando un effetto grafico molto carino.
Vorrei che l'utente che si muove all'interno della pagina con i tasti 
keyup e keydown possa scatenare un evento onmouseover sul link che ha il 
fuoco. Il fuoco riesco già a settarlo ma non riesco a far scatenare 
l'evento onmouseover sul <A> tag che ha il fuoco.
Pensavo, appunto di sfruttare setmouseposition per posizionare il mouse 
dove mi interessa e scatenare l'evento onmouseover.
Grazie a tutti quelli che mi vorranno aitare e soprattutto a te.
Francesco. 
Magilla il Gorilla Lilla <magilla@TOGLI_LE_MAIUSCOLEdespammed.com> ha 
scritto:

--
first.aid#
virgilio.it
(sostitisci # con @)
Inviato da 
www.mynewsgate.net

Appena tento di aprirlo IE mi blocca perché quella pagina cerca di caricarmi
un activex...


 
--


 livello di security dalle opzioni di IE e lasciar caricare l'activex.
Lo so, e non se ne parla proprio...


ti mando il contenuto della pagina.
We need to be able to turn our head. That's what we're going to work on this 
chapter. 
Let's use the mouse move event to control turning. One interesting thing to 
note about doing this is that we are going to need the capability to "trap" the 
mouse somewhere within the game window. If you are confused as to why this is 
necessary, take a look at the two scenes below. Put the mouse cursor inside 
each scene and drag left and right. Pretend this action is what's controlling 
your head turning. See the difference? 
 
In Scene A, you stop turning when the mouse cursor reaches the edges of your 
computer screen. That's no good if there's an alien just to your left and you 
can't blast him because you can't turn anymore! The solution is similar to what 
you see in Scene B. Here you can turn indefinitely and you'll never bump the 
mouse cursor up against the edge of the screen. You can do this by continuously 
using the method setMousePosition of the WT object to move the mouse cursor 
back to some location. 
NOTE: This tutorial was written for the Beta 3 of Web Driver 2.0. In this 
version, the only way to setMousePosition was to also have one of the mouse 
buttons pressed (or to play in full screen mode). This was to prevent a WT 
object from gaining complete control over a user's mouse. In later versions, it 
is possible to "trap" the mouse cursor in regular windowed mode without 
requiring a button to be pressed. But since this game was written for Beta 3, 
it was designed so that you have to DRAG the mouse to look around. 
Now that we have an idea of what we need to do in the mouse event (mouse) 
function, let's get back to the code. Remember how we passed the wtEvent object 
to the event functions? We're going to ask that object to give us information 
on the event by using the getType method. This will return us a number that 
decribes what kind of event occurred. Let's deal with the left mouse button 
down event, which returns a type 6. Inside the function mouse, add 
if( wtEvent.getType() == 6 )     // left button down
   {
      wt.setMouseCursorState( 0 );     // cursor invisible
   }
I thought it would be nice to make the arrow invisible, which I accomplished by 
using the setMouseCursorState method (0 is invisible, 1 would be visible). In 
English, the statements above read "If you click the left mouse button, make 
the cursor invisible." 
If we're going to make the mouse cursor invisible when we click, we should make 
it visible again when we release... 
if( wtEvent.getType() == 7 )    // left button up
   {
      wt.setMouseCursorState( 1 );    // cursor visible
   }
A left mouse button up event returns an event type of 7. 
Now let's get to the rotation stuff. The thing that we are going to rotate on 
mouse movement is not the gun or the camera, but the group, which contains 
both. We know that we are going to want to rotate the group about the up axis, 
but which up axis - the global up (in our case Z), or the group's local up 
(group's Y)? We need to think ahead a little bit. 
Eventually, we are going to allow the user to tilt their head up and down. If 
their head is tilted up and then they try to spin, you can see why it would 
matter whether we used the global or local up axis to spin about. If it's not 
clear, check out the scene below. The red arrow represents which way the player 
is looking and it's in a constant state of turning. Drag the mouse up and down 
to make the player look up and down and then try to the two methods of rotation 
that we talked about to see if you can figure out which axis we want to use for 
our rotation. The blue line represents the axis that you've selected. 
Try rotating the group about the...
group's local up axis 
global up axis 
 
So which axis do you think we should use?
 local up 
 global up 
We know that we are going to need to rotate using the setRotation method of the 
group. But how much? It would be nice if the amount of rotation was 
proportional to the amount that the mouse moved. Otherwise, you could give the 
mouse a sharp jerk and your player would spin the same amount as if you gave it 
a little push, because both are considered one mouse move event. So we need to 
figure out how much the mouse moved, which is easy using the getX method of the 
event object. This returns the 2-D X position (left to right) of the mouse 
within the WT scene on that event. Once we know how far the mouse moved (by 
subtract the X position from the X value at the middle of the scene, which is 
where we know the mouse started), we can rotate by some factor of that amount. 
We need to place everything we just described inside another conditional 
statement, because we don't want that stuff to happen on every mouse event - 
only when the mouse is moved while the left mouse button is held down. The 
mouse move event can be detected because it creates an event of type 2. The 
left button down is not an event itself, but a state that can still be detected 
from the wtEvent object by using the getButtonState method. This method returns 
a number telling you the button states of the mouse. "Left button down" returns 
a 1. Here's what it looks like in code. This needs to go inside the function 
mouse - I put it between the button down and button up conditions. 
if( wtEvent.getButtonState() == 1 && wtEvent.getType() == 2 )   // left button 
down AND mouse moved
   {
      turn = wtEvent.getX() - wt.getWidth()/2;
      if( Math.abs( turn ) >= 1 ) group.setRotation( 0, 0, 1, .1*turn, 1 );
   }
The number of pixels that the mouse moved in the X direction is stored in the 
variable turn. The method getWidth of the wt object returns the width of the 
object on the web page - divding it by 2 gives us the 2-D X value at the center 
of the object. 
Notice I put a conditional statement before the rotation so that the group will 
only rotate if the absolute value of turn is 1 or higher, so that we don't do 
any extra calls of the setRotation method. The first three parameters inside 
the setRotation method are the vector that we want to rotate around. The next 
parameter, .1 * turn, is the number of degrees that the group will rotate 
(proportional to the variable turn, which also accounts for rotation in both 
directions). The final parameter specifies to do the rotation in the global 
coordinate system. 0 would specify the group's local coordinate system. 
Remember that the key to getting constant mouse motion is constantly putting 
the mouse cursor back in the middle of the scene. The best place to do this is 
in the render event, because we are guaranteed that the render event will 
happen several times per second. However, we need to remember that the render 
event happens continuously, but we only want to reposition the mouse cursor 
when the mouse button is being held down. We should create a new state variable 
(let's call it MOUSEDOWN), declared globally, that we can always check to see 
if the mouse is down. First, put this in the global declarations: 
var MOUSEDOWN = 0;
I gave it an initial value of 0, which we'll use to mean "mouse is not down." 1 
will mean "mouse is down." Now we'll need to go back inside the event handler 
conditional statement for which the mouse button is pressed (back in the 
function mouse) and add 
MOUSEDOWN = 1;              
and inside the statement for which the mouse button is released, add 
MOUSEDOWN = 0;              
Now we get to the part where we need to make sure that the mouse is recentered 
constantly if the mouse button is down. The best place to do this is in the 
render event, because it is always happening! Here's what we need: 
if( MOUSEDOWN == 1 )
   wt.setMousePosition( wt.getWidth()/2, wt.getHeight()/2 );             
Put this line inside the function render. This puts the mouse cursor at half 
the width and half the height of the wt object, which is the middle of the 
screen. That should do it! 
In the next chapter, we'll give our player the ability to look up and down. 
This time the "Play game so far" button should actually be worth a click! 


 fose e` meglio "JScript" al posto di "javascript" ;o)
Ho provato a fare la ricerca come vuoi ma non trovo nessun esempio che mi 
consenta di muovere il mouse in una posizione specifica.


Ci rinuncio, mi spiace
 sta usando un oggetto Web Driver che è appunto un activex proprietario


 
grazie lo stesso sei stato gentile.
