RFR: 8262023: Scrolled button is pressed using Monocle on Raspberry Pi with Touchscreen
Alexander Scherbatiy
alexsch at openjdk.java.net
Fri Feb 19 16:14:40 UTC 2021
On Fri, 19 Feb 2021 15:56:02 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:
>> The issue is reproduced on Raspberry Pi 3 B+ with Touchscreen display.
>>
>> To reproduce the issue run the [ScrollPaneSample](https://bugs.openjdk.java.net/secure/attachment/93270/ScrollPaneSample.java) with Monocle:
>>> sudo jdk/bin/java -Dprism.verbose=true -Djavafx.platform=monocle -Dembedded=monocle -Dglass.platform=Monocle ScrollPaneSample
>>
>>
>> An application consists of a ScrollPane with buttons. if a button is touched by a finger, moved up/down and released, the button is scrolled and the button's action is fired.
>>
>> This happens because Monocle generates mouse pressed, mouse dragged, scroll, mouse released events when touch events are received.
>> Even a button is scrolled on a ScrollPane it still fires the button's action on the synthesized mouse release event.
>>
>> My first attempt was to add a scroll event listener to a ButtonBehavior class and disarm the button when the scroll event is received.
>> This does work not in the case where buttons are small and scrolling buttons leads that a finger is released on the next button (the scrolling process is remained a slightly behind the touched finger so the finger is touched on one button and released on another).
>> In this case all scroll events goes to the first button and the second button still fires its action (it does not disarmed because it does not receive scroll events).
>>
>> The current fix adds drag event listener to ButtonBehavior to disarm the button. Drag events goes to the touched and released buttons.
>>
>> Than I checked the fix on the same Raspberry Pi using GTK with touchscreen.
>>> sudo jdk/bin/java -Dprism.verbose=true -Djavafx.platform=gtk ScrollPaneSample
>>
>> I have not seen scroll events using GTK (even using -Dgtk.com.sun.javafx.gestures.scroll=true option), but GTK sends mouse drag events on a button touch.
>> The mouse drag event between a button touch and release events would disarm the button in the proposed ButtonBehavior drag event handler. So I added the check if the mouse drag is synthesized. If the mouse drag is synthesized (Monocle case on touchscreen) it disarms the button, otherwise (GTK case) not.
>>
>> I checked the fix for the following controls placed on a ScrollPane (see [ScrollPaneControlsSample](https://bugs.openjdk.java.net/secure/attachment/93271/ScrollPaneControlsSample.java) sample) :
>> - Fixed in corresponding behavior classes or its parents: Button, ToggleButton, CheckBox, ComboBox, ChoiceBox, ColorPicker, DatePicker, RadioButton
>> - Works because an action is not fired on mouse release event: TextField
>> - Does not work: Slider
>>
>> The Slider control does not work with the fix because it reacts not only on mouse release event but on mouse drag event as well. It requires a separate fix.
>>
>> I checked the Ensemble8 sample with the fix. It works with Monocle on Raspberry Pi 3B+ on Touchscreen. Scrolling the main page by a finger does not makes it to be pressed.
>>
>> The Ensemble8 sample does not work with GTK on Raspberry Pi 3B+ with Touchscreen. I see it generates scroll events ( it has its own [ScrollEventSynthesizer](https://github.com/openjdk/jfx/blob/master/apps/samples/Ensemble8/src/app/java/ensemble/ScrollEventSynthesizer.java)) and action events and it can makes the Ensemble8 buttons on a ScrollPane to be pressed.
>
> Can you provide an automated test for this?
>
> Since this is touching common code, what testing have you done to ensure no regressions on other platforms when not using Monocle?
>
> This will need careful review and testing.
I have Touchscreen only on Raspberry Pi so I checked the touch events only on JavaFX on arm with Monocle and GTK.
I also checked the fix with ScrollPaneControlsSample on Linux and Windows with ordinary screen and using only mouse (press, release, scroll) and the sample works with and without the fix.
I run all but webkit automated tests with the fix on Ubuntu `gradle test` and they passed.
I will look the way to provide an automated test.
I am interested if there is a better way to fix this. Handling scroll event would be straightforward (because the ScrollPane is used) but unfortunately it does not work when two controls are scrolled.
-------------
PR: https://git.openjdk.java.net/jfx/pull/406
More information about the openjfx-dev
mailing list