Empirisoft Support

    Welcome to Empirisoft Support
Results 1 to 6 of 6

Thread: Get mouse position using custom forms (case 12064)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Modified code to return x y coordinates of mouse click to Medialab

    Thanks for your support with this. Using your examples we managed to include an image of a sandpit which when clicked on passes the x and y position of the mouse back to Medialab.

    Our code here:
    <html>
    <head>
    <script language="JavaScript">
    function point_it(event){
    var pos_x=0;
    var pos_y=0;
    pos_x = event.offsetX?(event.offsetX):event.pageX-document.getElementById("pointer_div").offsetLeft;
    pos_y = event.offsetY?(event.offsetY):event.pageY-document.getElementById("pointer_div").offsetTop;
    document.getElementById("<ml.varname>_01").value = pos_x;
    document.getElementById("<ml.varname>_02").value = pos_y;
    document.sandpit.submit();
    }
    </script>
    </head>
    <body>
    <style>
    input.check {height: 50px; width: 50px;}
    <ml.styles>
    </style>
    <form name="sandpit" method="post">
    <div id="pointer_div" onclick="point_it(event)" style = "background-image:url('sandpit.jpg');width:928px;height:593px; ">
    </div>
    <br><br>
    <ml.wording>:<br><br>
    <input type="hidden" name="<ml.varname>_01"><br>
    <input type="hidden" name="<ml.varname>_02"><br>
    </form>
    </body>
    </html>

  2. #2
    Join Date
    Feb 2013
    Posts
    1,093
    Awesome! And thanks for posting the html code you used; this will be very helpful for other users to see.
    Jason Reed
    Empirisoft Software Support Specialist

Similar Threads

  1. Continous mouse position
    By rkreager in forum Hardware: How Do I...
    Replies: 3
    Last Post: 03-25-2021, 04:50 AM
  2. Resetting the mouse cursor position in between trials (case 1743)
    By gerardo in forum DirectRT v2018: How Do I...
    Replies: 2
    Last Post: 03-21-2013, 05:16 PM
  3. position and size of html in custom items
    By MandaHyde in forum MediaLab Older Versions: How Do I...
    Replies: 2
    Last Post: 10-29-2009, 12:43 PM
  4. Mouse position
    By rothers27 in forum MediaLab Older Versions: How Do I...
    Replies: 2
    Last Post: 07-08-2008, 04:09 PM
  5. custom item for tracking XY joystick/mouse movements
    By surpass in forum MediaLab Older Versions: How Do I...
    Replies: 3
    Last Post: 12-06-2007, 09:12 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •