Combining Horizontal swipe screen change (Outline) with a vertical list

116 views
asked Jun 4, 2019 in Embedded Wizard Studio by PhilShaw
Hi,

I have a combination of 3 screens, which are changed by swiping horizontally.

One of these screens is a vertical list.

The issue I have is if the touch surface is dragged diagonally, the resulting action is inconsistent depending on the angle.

Is it possible to narrow the range for the wipe left, wipe right etc to ignore diagonal swipes?

1 Answer

0 votes
answered Jun 5, 2019 by Paul Banach

Hi,

from your question I assume, you are using the Wipe Touch Handler to react to the horizontal wipe gestures and a Slide Touch Handler to scroll the list contents. I also assume you have configured the RetargetCondition of the Slide Touch Handler to resign if the user performs a horizontal gesture. Alternatively you have configured the Wipe Touch handler to resign in case of a vertical gesture. In this manner when the user performs a gesture the handler lying in front starts to process the interaction and if it decides to resign, it passes the interaction to the handler in the background.

This approach is simple and you don't need to code anything. It has however a peculiarity: the handler lying in front (while it processes the gesture) can also decide to resign. Let's assume the handler in front is the Slide Touch Handler. The user touches the screen and drags the finger diagonally. The handler processes the interaction and scrolls the list. Doing this the handler also evaluates the gesture direction and if it detects that the user evidently performs a horizontal gesture, stops the scrolling and resigns. From  now the Wipe Touch Handler in the background continues. The result is, during the interaction the list started to scroll before the wipe gesture were detected.

What can you do:

Option 1: arrange the Wipe Touch Handler in front of the Slide Touch Handler. In the RetargetCondition property of the Wipe Touch Handler set the both options WipeDown and WipeUp. In turn, for the Slide Touch Handler deactivate all options in its RetargetCondition. Now the Wipe Touch Handler decides what to do with a gesture. The scrolling at the begin of the gesture does not occure anymore. By using its property Threshold you can additionally specify how sensitive the Wipe Touch Handler should behave. 

Option 2: Use the Simple Touch Handler instead of the Wipe Touch Handler and implement your own algorithm to detect the gesture. In this case, also arrange the Simple Touch Handler in front of the Slide Touch Handler otherwise the Slide Touch Handler will start to scroll. In your algorithm implementation you process the gesture and decide what to do. If you decide to scroll the list, just perfom the following code to retarget the interaction to the Slide Touch Handler:

if ( you_have_detected_vertical_gesture )
  GetRoot().RetargetCursorWithReason( null, this, Core::RetargetReason[ WipeUp ]);

[... or ... ]

if ( you_have_detected_vertical_gesture )
  GetRoot().RetargetCursorWithReason( null, this, Core::RetargetReason[ WipeDown ]);

An example of the algorithm to detect the gestures can be found in the implementation of the Mosaic class Core::WipeTouchHandler class, concrete its method HandleEvent().

Best regards

Paul Banach

Embedded Wizard Website | Privacy Policy | Imprint

...