一天几次,我一次观察到多个触摸事件,而我只用一根手指触摸一个地方。
这些接触总是垂直的 = 几乎相同的 X 坐标,但 Y 坐标的大面积。我使用的是 1920x1080 分辨率。
我尝试了 2 种不同的触摸显示器,但行为相同——都是 iiyama T2235MSC-B1。我编写了 C++ 触摸应用程序来检查我的触摸屏,但这完全没问题,在 C++ 中没有这种行为。仅在 Java FX 中。我正在使用 OpenJDK 11.0.2 和 Windows 10。
每次只有当我触摸屏幕时才会发生这种情况。JavaFX 中是否有任何未正确清理的触摸事件缓存?你是否也观察到了这一点?我能做些什么?这是我在生产中的整个应用程序的一个亮点。
问题开始于
[DEBUG] 2019-03-01T12:03:38.740+01:00 [JavaFX Application Thread] (BaseScene.java:193) - TOUCH_PRESSED target button - ID fastB1, classes button keyboardBtn fastB1Style
[DEBUG] 2019-03-01T12:03:38.740+01:00 [JavaFX Application Thread] (BaseScene.java:214) - - touchEvent - setID = 1, touchPoint count = 1, point = [1163.0, 77.0]
[DEBUG] 2019-03-01T12:03:38.740+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1163.0, 77.0], state = PRESSED
[DEBUG] 2019-03-01T12:03:38.741+01:00 [JavaFX Application Thread] (BaseScene.java:193) - TOUCH_PRESSED target button - ID fastB2, classes button keyboardBtn fastB2Style
[DEBUG] 2019-03-01T12:03:38.741+01:00 [JavaFX Application Thread] (BaseScene.java:214) - - touchEvent - setID = 2, touchPoint count = 2, point = [1153.0, 148.0]
[DEBUG] 2019-03-01T12:03:38.741+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1163.0, 77.0], state = STATIONARY
[DEBUG] 2019-03-01T12:03:38.741+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1153.0, 148.0], state = PRESSED
…</p>
许多其他事件一一出现,直到大约 8 个固定事件同时出现:
[DEBUG] 2019-03-01T12:03:38.745+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1163.0, 77.0], state = STATIONARY
[DEBUG] 2019-03-01T12:03:38.745+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1153.0, 148.0], state = STATIONARY
[DEBUG] 2019-03-01T12:03:38.745+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1163.0, 239.0], state = STATIONARY
[DEBUG] 2019-03-01T12:03:38.746+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1160.0, 314.0], state = STATIONARY
[DEBUG] 2019-03-01T12:03:38.746+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1159.0, 413.0], state = STATIONARY
[DEBUG] 2019-03-01T12:03:38.746+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1160.0, 482.0], state = STATIONARY
[DEBUG] 2019-03-01T12:03:38.746+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1154.0, 539.0], state = PRESSED
[DEBUG] 2019-03-01T12:03:38.746+01:00 [JavaFX Application Thread] (BaseScene.java:193) - TOUCH_PRESSED target button - ID null, classes button keyboardBtn
[DEBUG] 2019-03-01T12:03:38.746+01:00 [JavaFX Application Thread] (BaseScene.java:214) - - touchEvent - setID = 8, touchPoint count = 8, point = [1150.0, 975.0]
[DEBUG] 2019-03-01T12:03:38.746+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1163.0, 77.0], state = STATIONARY
[DEBUG] 2019-03-01T12:03:38.746+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1153.0, 148.0], state = STATIONARY
[DEBUG] 2019-03-01T12:03:38.746+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1163.0, 239.0], state = STATIONARY
[DEBUG] 2019-03-01T12:03:38.747+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1160.0, 314.0], state = STATIONARY
[DEBUG] 2019-03-01T12:03:38.747+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1159.0, 413.0], state = STATIONARY
[DEBUG] 2019-03-01T12:03:38.747+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1160.0, 482.0], state = STATIONARY
[DEBUG] 2019-03-01T12:03:38.747+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1154.0, 539.0], state = STATIONARY
[DEBUG] 2019-03-01T12:03:38.747+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1150.0, 975.0], state = PRESSED
[DEBUG] 2019-03-01T12:03:38.806+01:00 [JavaFX Application Thread] (BaseScene.java:193) - TOUCH_RELEASED target button - ID fastB1, classes button keyboardBtn fastB1Style
[DEBUG] 2019-03-01T12:03:38.807+01:00 [JavaFX Application Thread] (BaseScene.java:214) - - touchEvent - setID = 18, touchPoint count = 8, point = [1163.0, 77.0]
[DEBUG] 2019-03-01T12:03:38.807+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1163.0, 77.0], state = RELEASED
[DEBUG] 2019-03-01T12:03:38.807+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1153.0, 148.0], state = STATIONARY
[DEBUG] 2019-03-01T12:03:38.807+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1163.0, 239.0], state = STATIONARY
[DEBUG] 2019-03-01T12:03:38.807+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1160.0, 314.0], state = STATIONARY
[DEBUG] 2019-03-01T12:03:38.807+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1159.0, 413.0], state = STATIONARY
[DEBUG] 2019-03-01T12:03:38.807+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1160.0, 482.0], state = STATIONARY
[DEBUG] 2019-03-01T12:03:38.807+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1154.0, 539.0], state = STATIONARY
[DEBUG] 2019-03-01T12:03:38.807+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1150.0, 975.0], state = STATIONARY
…</p>
然后开始一一递减:
[DEBUG] 2019-03-01T12:03:38.812+01:00 [JavaFX Application Thread] (BaseScene.java:197) - TOUCH_RELEASED No target/parent button/label - target is javafx.scene.control.TextField
[DEBUG] 2019-03-01T12:03:38.812+01:00 [JavaFX Application Thread] (BaseScene.java:214) - - touchEvent - setID = 23, touchPoint count = 3, point = [1160.0, 482.0]
[DEBUG] 2019-03-01T12:03:38.813+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1160.0, 482.0], state = RELEASED
[DEBUG] 2019-03-01T12:03:38.813+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1154.0, 539.0], state = STATIONARY
[DEBUG] 2019-03-01T12:03:38.813+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1150.0, 975.0], state = STATIONARY
[DEBUG] 2019-03-01T12:03:38.813+01:00 [JavaFX Application Thread] (BaseScene.java:193) - TOUCH_RELEASED target button - ID null, classes button lightGreen2 keyboardBtn
[DEBUG] 2019-03-01T12:03:38.813+01:00 [JavaFX Application Thread] (BaseScene.java:214) - - touchEvent - setID = 24, touchPoint count = 2, point = [1154.0, 539.0]
[DEBUG] 2019-03-01T12:03:38.813+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1154.0, 539.0], state = RELEASED
[DEBUG] 2019-03-01T12:03:38.813+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1150.0, 975.0], state = STATIONARY
[DEBUG] 2019-03-01T12:03:38.840+01:00 [JavaFX Application Thread] (BaseScene.java:193) - TOUCH_RELEASED target button - ID null, classes button keyboardBtn
[DEBUG] 2019-03-01T12:03:38.841+01:00 [JavaFX Application Thread] (BaseScene.java:214) - - touchEvent - setID = 30, touchPoint count = 1, point = [1151.0, 975.0]
[DEBUG] 2019-03-01T12:03:38.841+01:00 [JavaFX Application Thread] (BaseScene.java:216) - --> point: [1151.0, 975.0], state = RELEASED
编辑:
我想补充一点,我正在使用此代码绑定 EventHandler:
getScene().setOnTouchPressed(this);
getScene().setOnTouchReleased(this);
然后调用这个方法:
@Override
public void handle(InputEvent e) {
handleEvent(e);
}
private void handleEvent(InputEvent e) {…}
接触点以这种方式迭代(用于记录):
if (e instanceof TouchEvent) {
TouchEvent te = ((TouchEvent) e);
INPUT_EVENTS_LOGGER.debug("- touchEvent - setID = " + te.getEventSetId() + ", touchPoint count = " + te.getTouchCount() + ", point = [" + te.getTouchPoint().getScreenX() + ", " + te.getTouchPoint().getScreenY() + "]");
for (TouchPoint tp : te.getTouchPoints()) {
INPUT_EVENTS_LOGGER.debug("--> point: [" + tp.getScreenX() + ", " + tp.getScreenY() + "], state = " + tp.getState().name());
}
}