Mouse-position problem with a touch-screen


I have the following scenario:


jme-application using jme-desktop with a few swing-buttons (let's say button-1 and button-2)

And the problem I am registering is this:

When I push with my finger on the touch-screen trying to click on button-1 then the click-event happens but with the mouse-pointer in a different position to the one I am trying to click. So sometimes I do this on button-1 and as the mouse last-position was on button-2 then, the button-2 is clicked and not the butotn-1!

The point is that it seems that the mouse-move-event is not correctly updated before the mouse-click-event happens on the touch screen, so the position-before is happening, but no the new-position where the touch happened!!!

This is "dangerous" for the game I am implementing, as there is a user-interface in jme-desktop with a few buttons and when the user is touching button-1 the click-event is on a wrong position! the last position the pointer was located.

This is not happening in a normal computer (without touch-screen, as the mouse is moving and the it seems that the mouse-move event is correctly updated. But with a touch-screen, you know, there is no mouse, no mouse-move event then…)

Please, I need help to solve this in the scenario described.

How do I make jme to update correctly mouse-position on a touch-screen before mouse-click-event happens?

Thank you!

Hi, irrisor,

Thanks for your answer.

You are right, I'm doing MouseInput.get().setCursorVisible(false). I'm gonna do the opposite and will let you know.

Anyway, using cursor-visible=false, is there a manner to update the mouse-position before the mouse-click-event takes place?

or, let's say, updating the mouse-position on jme-top mouse-click-event before this is delegated to jme-desktop-swing?

I was playing with MouseInputListener, intending to capture mouse-click at jme-top, update the mouse-position, and then make jme-desktop-swing to receive a click with the mouse-position correct.  But not clear yet how to achieve this.


Try using MouseInput.get().setCursorVisible(true) - it uses the system cursor position then. Maybe you can hide the mouse cursor another way (e.g. using an empty cursor).

I don't know why it should be updated too late. So I don't know how it could be updated early either. You'll need to debug that events and see where it's being delayed (if it really is!).

Regarding "case mouse-visible=true and invisible-system-cursor" I still have to try it (as soon as I am in-situ with the touch-screen again).

Regarding "case mouse-visible=false and events" when using MouseInputListener I already observed the events and I get first the jme-top-mouse-click-event and then the jme-desktop-mouse-click-event, in this order. So, I was thinking on the idea of "updating mouse-position on jme-top-mouse-click-event before jme-desktop-mouse-click-event happens". But I cannot see clear how to stand-by jme-desktop-events while working on jme-top-events. I am not sure if this has any sense… :frowning:

Thanks for your help.

To explain it better, the problem I have is this (in time order):

  1. On the touch-screen I do a finger-push (mouse-click).
  2. jme receives that event and delegates jme-desktop-swing mouse-click-event.
  3. On jme-desktop-swing I receive the mouse-clik (over a button) and when I try to read the mouse-cursor-position I get a NULL OBJECT.

    This is not happening when I use a standard-swing-application in the touch-screen. It only happens when using swing in jme with jme-desktop.

    So it seems that with the touch-screen in jme the mouse-click-event is detected, but when delegating it to jme-desktop, the mouse-position is transferred as NULL to the swing-layer inside my jme-desktop.

    And why is that mouse-position = NULL? I guess it's because with the touch-screen you just do click-events (finger pushes) and you don't drag your finger on it (normally), so there are no mouse-move-events, but only-clicks. The ugly thing here then, is that jme is delegating correctly the mouse-click to the jme-desktop-swing-layer but with a NULL mouse-position because the mouse-move-event was not detected in jme.

    Is this possible? In case yes, where should I check in jme to solve the problem and update the mouse-position to a correct value (NOT NULL) before the jme-desktop-swing-layer receives the mouse-click-event?

    Thank you very much. I need help asap.

No idea where it should go wrong, sorry. And I don't have the time (nor the hardware) to investigate/debug.

Hi everybody.

I’m having the same problem. Anybody have any idea?

Uh, this thread is two and a half years old :wink: