1.6k views
in System Integration by
Hi, EW team:

        I met a specific GUI requirement. When 2 fingers touch screen and slide, the screen has to call out a new dialog, and the old one will not respond user.  The easiest idea seems to be using PresentDialog to present the new one. But the new dialog can not receive the continuous slide which was initially captured by the old one. Is there any way to overcome the difficulty?

      Thank you.

 

Best regards.

Stephen

1 Answer

0 votes
by
 
Best answer

Hello Stephen,

a touch interaction (once begun) remains associated to the original event handler. This so-called grab cycle ensures that the handler which has received a press event will not loose the control and also will receive a release event. See also Touch events and the grab cycle

This grab cycle can be terminated prematurely and the interaction can be relayed to a new event handler. In the simplest case you configure the so-called RetargetCondition in the original handler to achieve this. See also Combine several Touch Handlers together. As soon as the specified condition is fulfilled, the handler will try to find another handler which is willing to take over the interaction. This technique is used often to implement complex UI with nested lists and widgets the user can scroll and interact with.

More low-level approach is the usage of the methods RetargetCursor() or DeflectCursor(). The idea: the code executed in context of the actually active handler invokes the method to 'relay' the actual interaction to other handler. This could be the handler found in other component, e.g. in the previously presented dialog. This requires the code to have access to he component and to its handler. It means to 'know' them. You will need to remember the presented dialog e.g. in a variable so that the code triggered by the original handler can see whether the variable is initialized and relay the interaction in such case.

For example, following could be the implementation of a slot method associated to the original handler. That means the code is executed in context of the original handler:

// Is there is a dialog presented, relay the interaction to its handler
if ( the_dialog )
  GetRoot().DeflectCursor( the_dialog.SomeTouchHandler, <0,0>);

If you plan to use dialogs, please remind that the dialogs appear asynchronously. That mean, that the effect of PresentDialog() has a delay. Even if the_dialog from the code above exists already, it can eventually be not yet visible and not yet ready to handle touch events. If the dialog does not perform any animations, following could be sufficient. Now the code is executed when the dialog is already part of the view tree:

// Is there is a dialog presented and already visible, relay the interaction to its handler
if ( the_dialog && the_dialog.Owner )
  GetRoot().DeflectCursor( the_dialog.SomeTouchHandler, <0,0>);

Well, so far technical backgrounds. I'm not sure whether it helps you further or not. From our experience, I would recommend other approach. Let the original handler handle the user interaction. That means, when the user taped with two fingers and dragged them, present the new dialog but let the original handler continue handling the events. Just limit to invoke a method in the presented dialog to inform it about the performed drag operation. The dialog can then update its state/position etc. For example:

// Is there is a dialog presented, then just inform it about the dragged finger
if ( the_dialog && the_dialog.Owner )
  the_dialog.SomeUpdateMethod( TouchHandler.CurrentPos );

Best regards

Paul Banach

by

Hello paul:

     At my computer, install 2 version Embedded Wizard,version 11.00.01 and 12.00,  11.00.01 is for my formally project, 12.00 use for EW example project.

Follow your comment, i try to change limit time about 2-finger-gesture.

     Step 4: Within the Mosaic folder look for the file named Core.ewu.

     Step 5: Open the file in a text editor.

     Step 6: Search for the following code line:

     int8 multiFingerDelay;

     but at my Core.ewu, i can't find the variable multiFingerDelay. i have try to search the string "multiFingerDelay" "multiFinger" "Delay", can't find the string "multiFingerDelay"

  That have some other way to achieve my target?or how to resolve the not find problem?

by
At the time, i search the string "Delay" at Core.ewu , i can find some string like: RetargetDelay, CursorSequelDelay, ResetDelay.....

but when i use the same process search "multiFingerDelay" "multiFinger", it find nothing
by

Hello ke007,

you are right. The mentioned variable multiFingerDelay was introduced in version 12. Older versions ( <= 11) contain only following line of code calculating with constant 50 ms:

If you are working with version 11 thus I suppose, replacing 50 with a higher value could produce similar results. However, I haven't tested it yet. If you are working with version 12, the variable is already available, so you can follow the steps above.

Please note, some time ago we have detected an issue with the redirection of multi-touch events. In some cases the events were not relayed as expected between multiple stacked touch handlers. The issue is especially noticeable when comparing version <= 11 with version >= 12. We plan to release this correction officially in the next version.

If you observe undesired behavior with the handler, we could provide you a patch containing the mentioned fix so you would verify this improvement. Let me know.

Best regards

Paul Banach

by

Hello paul

Thanks for your answer!

For the constant 50 ms, I will have a try, and return the result to you.

And for the issue about redirection,I don't know the example-2 is for this reason or not?

2 finger SlideTouchHandler intervene with SimpleTouchHandler - Ask Embedded Wizard (embedded-wizard.de)

 

If it is the redirection issue, please provide the patch .

 

thank you so much

by

Hello ke007,

If it is the redirection issue ...

Because of so many different issues you have reported, it is difficult to deduce what's wrong. Using the patch could at least remove one error source. I can prepare a patch for the version 12 or 13. Because of dependencies the version 11 is too old unfortunately. Is it ok? If yes, please contact us via support@embedded-wizard.de.

Best regards

Paul Banach

Embedded Wizard Website | Privacy Policy | Imprint

...