MouseMovedEvent in ViewerCanvas

Help
Pete
2016-11-14
2016-12-01
  • Pete

    Pete - 2016-11-14

    Hi.

    It seems that there are a couple of cases, when it would be useful to recognize the moving mouse cursor, when no buttos are being pressed. Now, what I find in ViewerCanvas seems to disturb that plan a bit.

        addEventLink(MouseDraggedEvent.class, this, "processMouseDragged");
        addEventLink(MouseMovedEvent.class, this, "processMouseDragged"); // Workaround for Mac OS X bug
    

    Any recommendations how to work around that?

    What comes to my mind is, that I'd put a check in the beginning of the processMouseDragged() that redirects the function to a processMouseMoved() method if no mouse button is down.

     
    Last edit: Pete 2016-11-15
  • Luke S

    Luke S - 2016-11-14

    This one looks like it may be messy no matter which way we slice it. I think that we should ask @Peter if the OSX bug is a bouy bug, or an actuall bug in the mac API. If it's a bouy bug, maybe we should fix that, rather than extending and complicating the workaround hack.

     
  • Peter Eastman

    Peter Eastman - 2016-11-15

    It's probably a bug that doesn't exist anymore. Apple stopped developing their own Java years ago and moved to using OpenJDK.

     
  • Luke S

    Luke S - 2016-11-15

    Well, that would make things simple.... Shall I test that theory with the next beta? We just need to remove that line and have someone with a mac try to do a mouse-drag action...

     
  • Pete

    Pete - 2016-11-15

    put a check in the beginning of the processMouseDragged()

    Hmm... Naturally the check was already there in the. A boolean called dragging was set true at mousePressed(). Strangely, the boolean was not necessarily ever set false again but the thing still worked. At mouseDragged() there seems to be no mouse event to capture if all the buttons are up (at least getPoint() returns null on a Windows system).

    I tested a few ideas but there seem to be quite a few things to be figured out anway. One tiny mystery is that MoveMouseEvent and DragMouseEvent return a different pixel by getPoint(). I guess there is a reason, but I just wonder what that might be.

     
    Last edit: Pete 2016-11-15
  • Pete

    Pete - 2016-11-15

    And this too (and what ever follows) seems to be OK to the compiler:

        addEventLink(MouseDraggedEvent.class, this, "processMouseDragged");
        addEventLink(MouseMovedEvent.class, this, "processMouseDragged"); // Workaround for Mac OS X bug
        addEventLink(MouseMovedEvent.class, this, "processMouseMoved");
    

    What happens then, may be a different thing....

     
  • Peter Eastman

    Peter Eastman - 2016-11-16

    It's been a long time, but as far as I can remember, the problem was that if you dragged with a particular modifier key held down (I think control, but I'm not sure), it sent MouseMoved instead of MouseDragged events.

     
  • Pete

    Pete - 2016-12-01

    After some testing, it is possible to send the MouseMovedEvent to both methods and have the methods figure out wich one does somethig. Basically there's something like

    boolean mouseMoving, mouseDragging;
    ...
    drawOverlay()
    {
        if (mouseDragging)
             // then mouseMoving is ignored
    }
    

    The mouseMoving is set true by the mouseMoved() method and back false by a Timer.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks