2 Replies Latest reply on Feb 26, 2012 11:53 AM by Jhon Carlo

    MouseDown with keyboard. Strange question, perhaps impossible, but it need it.

    Jhon Carlo Level 1

      Is it possible to assign a function equivalent to the mouseDown to a keyboard key? (With some script).

      I should do a "mousedown" with the keyboard in relation to the position where the mouse is clicked the last time on the sprite or on the Stage.

      Thank you.

        • 1. Re: MouseDown with keyboard. Strange question, perhaps impossible, but it need it.
          James Newton, ACP Level 3

          It can be done. There are two main solutions: use an xtra to trigger a mouse click, or roll your own solution in Lingo.

           

          You can use the keyDownScript to intercept a keypress and the mouseDownScript to intercept mouse clicks. You can use these primary event handlers to send a message to a given script each time the mouse is clicked or a key is pressed. You can use this script to save the location of the last mouse click. You use the clickOn and the clickLoc to determine where the click occurred and which sprite was under the mouse. You can send a #mouseDown message to that sprite, with the clickLoc as a parameter.

           

          You can create a behavior on each sprite that as likely to be clicked, and give it a special "on mouseDown(me, aLoc)" handler. If the aLoc parameter is a point, then you will know that the call was sent by your keyDownScript process. You can create a movie script to handle clicks on the Stage. This call...

           

            sendSprite(0, #mouseDown, the clickLoc)

           

          ... will send trigger the "on mouseDown" handler in a movie script. You should use the same format as for a behavior:

           

            on mouseDown(me, aLoc)

           

          The "me" parameter in the movie script will receive the symbol #mouseDown, if the message is sent from your keyDownScript process.

           

          Does this help?

          • 2. Re: MouseDown with keyboard. Strange question, perhaps impossible, but it need it.
            Jhon Carlo Level 1

            Sure it is the answer I was waiting. I need to test it if I have problems I'll let you know.
            Thanks a lot.