RFR: 8262023: Scrolled button is pressed using Monocle on Raspberry Pi with Touchscreen
Jose Pereda
jpereda at openjdk.java.net
Mon Apr 26 20:44:42 UTC 2021
On Fri, 19 Feb 2021 14:19:35 GMT, Alexander Scherbatiy <alexsch 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.
modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/behavior/ButtonBehavior.java line 241:
> 239: * Invoked when the the Button is dragged. If the Button had been armed
> 240: * by a touch event or a mouse press and the mouse is still pressed,
> 241: * then this will cause the button to be rearmed. This allows not to fire
then this `would` cause...
modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/behavior/ChoiceBoxBehavior.java line 161:
> 159: * Invoked when the the ChoiceBox is dragged. If the box had been armed
> 160: * by a touch event or a mouse press and the mouse is still pressed,
> 161: * then this will cause the ChoiceBox to fire the box's action. This allows not to fire
then this `would` cause ..
modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/behavior/ChoiceBoxBehavior.java line 165:
> 163: */
> 164: protected void mouseDragged(MouseEvent e) {
> 165: if(e.isSynthesized()) {
missing spacing after `if`
modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/behavior/ComboBoxBaseBehavior.java line 270:
> 268: * Invoked when the the ComboBox is dragged. If the box had been armed
> 269: * by a touch event or a mouse press and the mouse is still pressed,
> 270: * then this will cause the box to be rearmed. This allows not to fire
then this `would` cause
modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/behavior/ComboBoxBaseBehavior.java line 274:
> 272: */
> 273: public void mouseDragged(MouseEvent e) {
> 274: if(e.isSynthesized()) {
missing spacing after `if`
modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/inputmap/InputMap.java line 883:
> 881: * @param eventHandler The {@link EventHandler} to fire when the
> 882: * {@link MouseEvent} is observed.
> 883: * @param autoConsume Auto consume mouse events
probably more descriptive: `@param autoConsume When true, mouse events are auto consumed`
-------------
PR: https://git.openjdk.java.net/jfx/pull/406
More information about the openjfx-dev
mailing list