On Fri, 19 Feb 2021 14:19:35 GMT, Alexander Scherbatiy <alex...@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.

Running ScrollPaneSample on my Pi 4 with the proposed changes works fine. 
Scrolling works and the buttons are not fired unless you stop scrolling and 
press one of them. Without the changes, the button that was selected when 
scrolling started gets fired right after scrolling finishes.

There is a minor issue: when you start scrolling, the button that gets touched 
(but not fired) in the first place gets focused (but this is not happening as a 
consequence of such changes). 

There is also another issue, this time related to the changes: if you have a 
very small input touch radius (`-Dmonocle.input.touchRadius=1`) it is really 
hard to do a regular click on a button: with very small radius it is easier 
that the touch press event turns into a drag event, and then the button will be 
disarmed. While setting this tiny radius on a Pi seems unnecessary (due to low 
resolution), this is a usual value on Android, where the issue will happen as 
well.


Running ScrollPaneControlsSample works as well: with the proposed changes it 
works fine. Scrolling works and the controls are not fired unless you stop 
scrolling and press one of them. Without the changes, the control that was 
selected when scrolling started gets fired right after scrolling finishes.

Same issues as well: When you start scrolling, the control that gets touched 
(but not fired) in the first place gets focused. This has the side effect on a 
TextField that the keyboard (if enabled) shows up when scrolling finishes. 
Ideally, this shouldn't happen if you are finishing scrolling, unless you tap 
again on it to enable edit mode.
Click issue: firing a control is now harder for the same reason mentioned 
earlier.

Both TextField (TextArea) and Slider issues will require a follow-up issue.

-------------

PR: https://git.openjdk.java.net/jfx/pull/406

Reply via email to