I work on a Raspberry project. The purpose of this project is to use a Raspberry to control industrial machines. For this, the users use a touch screen.
My problem
I have a screen with several button (around 20). When I press several button, wrong button are pressed.
I think that a exemple will be clearer :
| A | B | C |
| D | E | F |
Let's imagine that each cell are a button.
If I press the following sequence : A, B, B, C, A, B, A. The buttons activated are : A, B, B, B, B, B, A.
I need to wait around 5 seconds between each touch to avoid this problem.
My research
I have added this in my code :
stage.addEventFilter(TouchEvent.ANY, touchEvent -> {
LOGGER.info("TOUCH : X = " + touchEvent.getTouchPoint().getX() + ", Y = " + touchEvent.getTouchPoint().getY());
});
And when I touch my screen, the corrects coordinates are show.
In fact it is this event that is raised when it should not be :
//b is a Button
b.setOnAction(actionEvent -> {
LOGGER.debug(b.getText() + " pressed.");
});
The OnMouseClick event has the same problem.
I have tried to change the touch screen, and the problem no longer occurs.
The second touch screen is connected on DSI port while the one that causes the problem is on HDMI (+ usb link for touch).
They also have a difference in resolution, the first (problem) 1024x600 and the second (no problem) 800x480.
I admit that I don't know how to correct this problem.
I use Java 11 with Javafx 11.
EDIT: After retrying this :
stage.addEventFilter(TouchEvent.ANY, touchEvent -> {
LOGGER.info("TOUCH : X = " + touchEvent.getTouchPoint().getX() + ", Y = " + touchEvent.getTouchPoint().getY());
});
I have this result :
2021-02-22 09:40:47 INFO App:71 - TOUCH : X = 627.0, Y = 318.0
2021-02-22 09:40:47 INFO App:71 - TOUCH : X = 627.0, Y = 318.0
2021-02-22 09:40:47 INFO App:71 - TOUCH : X = 627.0, Y = 318.0
--
2021-02-22 09:40:47 INFO App:71 - TOUCH : X = 705.0, Y = 300.0
2021-02-22 09:40:47 INFO App:71 - TOUCH : X = 627.0, Y = 318.0
2021-02-22 09:40:47 INFO App:71 - TOUCH : X = 705.0, Y = 300.0
The first three have been displayed when I have pressed on the button A (for example) and the last three have been displayed when I have pressed B. But finally, button A was pressed twice according to my program when in reality I have ressed A and then B.