Retrieve Mouse Coordinates by JavaScript

   Hi folks,
is there a way to retrieve current mouse coordinates (x, y) by using client side JavaScript?
thank you

I would first like to know, how are you going to implement the drag-drop functionality within Adobe Form?

Similar Messages

  • Flash player in firefox is not giving the exact mouse coordinates while running a flex application in firefox. Actually it was working fine in the previous versions. I mean in the ver 5.5. In the latest version its not working fine

    Hi Friends,
    I face some mouse issues with the later versions of the Firefox (6 and above). When a flex application is executed in a Firefox, It runs on the flash player in the browser. While getting the mouse coordinates, flash player is returning some bad coordinates. Please respond to this as soon as possible

    A good place to ask advice about web development is at the mozillaZine Web Development/Standards Evangelism forum.<br />
    The helpers at that forum are more knowledgeable about web development issues.<br />
    You need to register at the mozillaZine forum site in order to post at that forum.<br />
    See http://forums.mozillazine.org/viewforum.php?f=25

  • About get mouse coordinates on screen?

    how to get mouse coordinates in java, i don't look for a appropriate method.

    The MouseEvent which is given to the MouseMotionListener or the MouseListener has one getX() and one getY() method. That are the coordinates in your applicetion window starting with (0,0) in the upper left corner.
    Hope this helps
    Markus

  • Mouse Coordinate issues caused by Scaling Components in a JScrollPane

    Hi All,
    I've been attempting to write a program that includes a simple modeler. However, I've been having some trouble with being able to select components when attempting to implement zoom functionality - when I "zoom" (which is done via scroll wheel) using the scale Graphics2D method, while it zooms correctly, the mouse location of components do not seem scale.
    I've tried one of the solutions found on the forums here (create a custom event queue that adjusts the mouse coordinates) and while it seemed to work initially, if I zoom in and adjust the current view position using the scrollbars, certain components contained in the JPane will become un-selectable and I haven't been able to work out why.
    I've attached a SSCCE that reproduces the problem below - it implements a JScrollPane with a JPane with a few selectable shapes set as the Viewport. The zoom is done using the mouse scroll wheel (with wheel up being zoom in and wheel down being zoom out)
    Any help in order to fix the selection/de-selection issues on zoom would be greatly appreciated! I've spent some time reading through the forums here but have unfortunately not been able to find a workable solution around it.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class Tester extends JScrollPane
        public Tester() {
            this.setViewportView(new Model());
        public static void main (String[] args) {
            JFrame main = new JFrame();
            main.add(new Tester());
            main.setSize(500,300);
            main.setResizable(false);
            main.setVisible(true);
    class Model extends JPanel implements MouseListener, MouseWheelListener
        private GfxClass selection = null;
        private static double zoomLevel = 1;
        // zoom methods
        public void setZoom(double zoom) {
            if( zoom < 0 && zoomLevel > 1.0)
                zoomLevel += zoom;
            if( zoom > 0 && zoomLevel < 5.0)
                zoomLevel += zoom;
        public static double getZoom() { return zoomLevel; }
        public void resetZoom() { zoomLevel = 1; }
        public Model() {
            super(null);
            addMouseListener(this);
            addMouseWheelListener(this);
            MyEventQueue meq = new MyEventQueue();
            Toolkit.getDefaultToolkit().getSystemEventQueue().push(meq);
            for(int i = 0; i <7; i++) {
                double angle = Math.toRadians(i * 360 / 7);
                GfxClass oc_tmp = new GfxClass((int)(200 + 150 * Math.cos(angle)), (int)(125 + 100 * Math.sin(angle)), "Element"+i);
                add(oc_tmp);
            repaint();
        public void paint (Graphics g) {
            Graphics2D g2 = (Graphics2D) g.create();
            AffineTransform oldTr=g2.getTransform();
            g2.scale(getZoom(),getZoom());
            super.paint(g2);
            g2.setTransform(oldTr);
            setBackground (Color.white);
            super.paintBorder(g2);
        private static class MyEventQueue extends EventQueue  {
            protected void dispatchEvent(AWTEvent event) {
                AWTEvent event2=event;
                if ( !(event instanceof MouseWheelEvent) && (event instanceof MouseEvent) ) {
                    if ( event.getSource() instanceof Component && event instanceof MouseEvent) {
                        MouseEvent me=(MouseEvent)event2;
                        Component c=(Component)event.getSource();
                        Component cursorComponent=SwingUtilities.getDeepestComponentAt(c, me.getX(), me.getY());
                        JPanel zContainer= getZoomedPanel(cursorComponent);
                        if (zContainer!=null) {
                            int x=me.getX();
                            Point p=SwingUtilities.convertPoint(zContainer,0,0,(Component)event.getSource());
                            int cX=me.getX()-p.x;
                            x=x-cX+(int)(cX/getZoom());
                            int y=me.getY();
                            int cY=me.getY()-p.y;
                            y=y-cY+(int)(cY/getZoom());
                            MouseEvent ze = new MouseEvent(me.getComponent(), me.getID(), me.getWhen(), me.getModifiers(), x, y, me.getClickCount(), me.isPopupTrigger());
                            event2=ze;
                super.dispatchEvent(event2);
        public static JPanel getZoomedPanel(Component c) {
            if (c == null)
                return null;
            else if (c instanceof Model)
                return (Model)c;
            else
                return getZoomedPanel(c.getParent());
        private void deselectAll() {
            if(selection != null)
                selection.setSelected(false);
            selection = null;
        public void mouseClicked(MouseEvent arg0)  {    }
        public void mouseEntered(MouseEvent arg0)  {    }
        public void mouseExited(MouseEvent arg0)   {    }
        public void mouseReleased(MouseEvent arg0) {    }   
        public void mousePressed(MouseEvent me) {
            Component c1 = findComponentAt(me.getX(),me.getY());
            if(c1 instanceof GfxClass)
                if(selection != null)
                    selection.setSelected(false);
                selection = (GfxClass)c1;
                selection.setSelected(true);
            else
                deselectAll();
            repaint();
            return;
        public void mouseWheelMoved(MouseWheelEvent e) { // controls zoom
                int notches = e.getWheelRotation();
                if (notches < 0)
                    setZoom(0.1);
                else
                    setZoom(-0.1);
                this.setSize(new Dimension((int)(500*getZoom()),(int)(300*getZoom())));           
                this.setPreferredSize(new Dimension((int)(500*getZoom()),(int)(300*getZoom())));     
                repaint();
    class GfxClass extends Component { // simple graphical component
        private boolean isSelected = false;
        private String name;
        public GfxClass(int xPos, int yPos, String name) {
            this.name = name;
            this.setLocation(xPos,yPos);
            this.setSize(100,35);
        public void setSelected(boolean b) {
            if( b == isSelected )
                return;
            isSelected = b;
            repaint();
        public boolean isSelected() {
            return isSelected;
        public void paint(Graphics g2) {
            Graphics2D g = (Graphics2D)g2;
            if( isSelected )
                g.setColor(Color.RED);
            else
                g.setColor(Color.BLUE);
            g.fill(new Ellipse2D.Double(0,0,100,35));
            g.setColor(Color.BLACK);
            g.drawString(name, getSize().width/2 - 25, getSize().height/2);
    }Edited by: Kys99 on Feb 22, 2010 9:09 AM
    Edited by: Kys99 on Feb 22, 2010 9:10 AM

    Delete your EventQueue class. Change one line of code in your mouse pressed method.
    public void mousePressed(MouseEvent me) {
        Component c1 = findComponentAt((int) (me.getX()/getZoom()),
                                       (int) (me.getY()/getZoom()));
    }

  • In Photoshop CS6 how do I turn off the move tool popup showing the mouse coordinates?

    I just installed Creative Suite CS6 and in Photoshop, when I use the move tool a small popup window shows the mouse coordinates. I can't see any option to turn this off, either in the Options bar or the Preferences. It's really annoying. Can someone please help?
    Thanks,
    Joanne

    Thank you so much! Sometimes I miss the lack of user manuals but I know it saves trees.

  • Plotting on xy graph based on mouse coordinates

    I am looking into plotting Mouse coordinates on XY Graph continuously based on where i move. My computer's resolution is 1200x800 and i would like it to plot based on where i move.,
    Attached is my progress so far.
    Attachments:
    progress.png ‏74 KB

    The XY Graph has a method which converts coordinates to XY values. You can call it by right clicking the graph and selecting Create>>Invoke Node>>Map Coordinates to XY.
    However, if you look at the help for it, you will see that the coordinates it expects are those of the pane the graph is in, and the coordinates you have are of the screen. You can convert your global coords to pane coords by getting the VI's Front Panel Window. Panel Bounds property, building two matching XY clusters from the data and subtracting them (assuming the VI only has one pane) or you can use another loop with an event structure and a Mouse Move event (which returns local data) on the graph and then transfer the position data to your loop (you could also use a single loop, but that might be more complicated because the event structure will process every move of the mouse as a new event).
    You will also need to keep the data to place in the graph somewhere. If you open the context help window and hover over the graph's BD terminal, you will see the data types it expects and you will need to build one of those yourself. A shift register is something you might want to look into. There are also some examples showing working with graphs in the example finder (Help>>Find Examples).
    Try to take over the world!

  • Mouse coordinate in oracle form canvase

    Hi,
    Is there any way to know the mouse coordinate when the mouse is moving in oracle form canvase.
    I will appreciate for help..... Thanks.
    Regards,

    System variables should give u information
    this forms example might help
    /* Trigger:  When-Mouse-Click
    **   Example:  Dynamically repositions an item if:
    **             1) the operator clicks mouse button 2
    **                on an item and
    **             2) the operator subsequently clicks mouse button
    **                2 on an area of the canvas that is
    **                not directly on top of another item.
    DECLARE
       item_to_move       VARCHAR(50);
       the_button_pressed VARCHAR(50);
       target_x_position  NUMBER(3);
       target_y_position  NUMBER(3);
       the_button_pressed VARCHAR(1);
    BEGIN
       /* Get the name of the item that was clicked.
       item_to_move := :System.Mouse_Item;
       the_button_pressed := :System.Mouse_Button_Pressed;
       **  If the mouse was clicked on an area of a canvas that is
       **  not directly on top of another item, move the item to
       **  the new mouse location.
       IF item_to_move IS NOT NULL AND the_button_pressed =  '2' THEN
          target_x_position := To_Number(:System.Mouse_X_Pos);
          target_y_position := To_Number(:System.Mouse_Y_Pos);
          Set_Item_Property(item_to_move,position,
              target_x_position,target_y_position);
          target_x_position := NULL;
          target_y_position := NULL;
          item_to_move := NULL;
       END IF;
    END; plz mark correct/helpful if it is

  • Mouse Coordinates and Timer Resolution

    First - I am not a Flash or ActionScript programmer. I have
    been asked by someone if I could port my ActiveX code (private) to
    the Flash client. In researching all of the Flash, Flex and
    ActionScript documentation, it appears that almost everything I
    need is present... Almost....
    A. My program relies on Mouse Coordinates being fed to it in
    twips. The only possible references I get to this issue have come
    from searching this forum.
    - Is it true that the X and Y coordinates are returned to
    ActionScript as floating point values that represent fractional
    pixel values that I can translate to twips?
    B. My program also relies on good timer resolution. The
    Windows GetTicks() API is not sufficient, because it is returned
    via the Windows message queue and can be off enormously at a
    MouseMove event. Therefore, in my ActiveX code, I call the
    QueryPerformanceCounter(), which gives me the resolution I need.
    - Can anyone tell me what timer API the Flash client engine
    is using for the values it returns?
    Thank you,
    Grant

    I still don't understand your problem and apparently nobody else does either since there are no responses. Why don't you write a simple program (like I did for you on your last post) that demonstrates the problem.
    "A picture is worth a thousand words".

  • GeoMap Mouse Coordinates to Longitude & Latitude

    Is there a method on GeoMap to take the mouse coordinates generated by attachBrowserEvent('click', onClick) ev.getOffsetX(), into map coordinates (Lng & Lat)? I was hoping that the attachClick method would have provided an event with geo-coordinates, but attachClick doesn't seem to be working so I was advised to use attachBroswerEvent instead.

    Please close discussion by choosing correct answer - How to close a discussion and why

  • Mouse coordinates on af:image

    Hie
    I have an image using af:image component.
    I want to get the coordinates at the point where user clicked on the image.
    How to do it in adf . I am using 11.1.1.5 11g
    Please advise/

    You can try using client listeners & java script as in the following post:
    http://www.emanueleferonato.com/2006/09/02/click-image-and-get-coordinates-with-javascript/
    Thanks,
    Navaneeth

  • Mouse coordinates on the screen

    is it possible to get mouse coordinates on the screen? i want to make a program which makes screenshots of areas on the screen and i want use the mouse to mark them.
    how could i do that? is it possible to get mousecoordinates even if the mouse is outside the java JFrame?
    there must be a way! i searched in the forum but i found no answer.
    please don't tell me i have to use jni, the app should be platform independent.

    Yeah, basically there's no way to do this. This should be requested if it hasn't already (too lazy to check). It's not hard for sun to add, they just need to add it. Ok, anyway, I looked into it and see if there was a way to do this even somewhat reasonably in Java. I was very disappointed. I pretty much had no luck, but I did get a lame way of implementing this :P After some thought, this is what I ended up with:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class MousePosition extends JFrame implements MouseMotionListener
        private int x = 0;
        private int y = 0;
        private boolean isAP = true;
        public MousePosition()
            setSize(300, 300);
            setLocation(200, 200);
            addMouseMotionListener(this);
            addMouseListener(new MouseAdapter()
                public void mousePressed(MouseEvent e)
                    isAP = false;
            setVisible(true);
            try
                Robot r = new Robot();
                r.mouseMove(getLocation().x + 50, getLocation().y + 50);
                r.mousePress(InputEvent.BUTTON1_MASK);
            } catch(AWTException e) {}
        public void mouseDragged(MouseEvent e)
            System.out.println(e.getX() + getLocation().x + ", " + (e.getY() + getLocation().y));
        public void mouseMoved(MouseEvent e) {}
        public static void main(String[] args)
            new MousePosition();
    }So it'll "lock" the program getting the absolute coordinates until you press the mouse, then you're free to do what you want. You could also do this with keyPressed or anything else you want. JNI would be the real solution as of now, until then I think sun should address the problem.

  • Mouse coordinates.

    I want to make an applet (dimensions cca 50x100).
    But I want it to display the mouse coordinates, no matter where the cursor is (over the applet or elsewhere on the desktop).
    Can you give me some ideas? What classes to use, some approaches to my problem etc.
    Advanced thanks (like this forum is).
    iulian

    I think your only way out of this would be to use JNI. On Windows you can then use thr MouseCapture functions (or a hook function) to get mouse messages wherever the mouse is, but of course that is platform specific. Otherwise, the JVM will only get mouse messages when the mouse is over the Java window(s)

  • Get mouse coordinates when its moved over a powerpoint slideshow -URGENT

    i am writing a code to get the mouse coordinates as its moved over the screen(especially over powerpoint slide show. plz help me if u know a simple code that perform this function without a plug-in, but if i have to use a plug-in advice me.
    tahnk u very much :)

    sorry for not using the code tags..just learn about it...thanx
    my problem is.when i want to record every coordinates of the mouse while it moves..but using the printstream,it only records the end point of the mouse and not while the mouse moves/dragged.I'm developing a sketch pad program. the program needs to capture the coordinates and saved it into a file.i tried using it but keeps on saving the last point but not all
    example
    point A..........................point N............................point Z
    i want the program to save the coordinate of point A,point B,C,D...point N....and last point Z
    but it keeps on saving only point Z.can u help or give any ideas..thanx

  • How to find out the mouse Coordinates

    How can I find out the mouse coordinates, where I am clicking on the screen.
    I tried to use MouseEvent e, e.getX() and e.getY() but it is giving that particular components X,Y coordinates

    In SwingUtilities there is a method called that can be used to convert a local location to a screen location.
    public static void convertPointToScreen(Point p,
    Component c)
    Convert a point from a component's coordinate system to screen coordinates.
    Parameters:
    p - a Point object (converted to the new coordinate system)
    c - a Component object

  • Mouse coordinates (0,0) at the center of the monitor screen on computer

    Is it possible to have the mouse coordinates at (0,0) at the center of the screen of the laptop /monitor of the PC instead of the top left hand corner of the computer?

    Hm, not entirely true.
    The point is: "What does 0,0 refer to?"
    Windows is using the top left corner of the primary monitor as 0,0. So my previous repliers are correct.
    But when relating coordinates to specific windows, the 0,0 could be elsewhere. Typically, those relative coordinates also refer to the top left corner (0,0), but this can change.
    In LV for instance, you see the relative 0,0 coordinate of the front panel by the crossing and the dot (grey) if you have the grid enabled. Initially, the dot (0,0) is located in the top left corner, but it could be moved.
    On the other hand, there is no easy way to move 0,0 of the front panel to the center of your application window as it depends on the size of the window. You can do it though using property nodes (VI=>Panel=>Pane=>Origin).
    hope this helps,
    Norbert
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

Maybe you are looking for