一天几次,我一次观察到多个触摸事件,而我只用一根手指触摸一个地方。
这些接触始终是垂直的= 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
...
许多其他事件一一出现,直到大约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
...
然后一一减少:
[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());
}
}