Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Examples for overriding BaseTouchBehavior and implementing a TouchController (Read 2226 times)
dpru2
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 19
Joined: Feb 2nd, 2021
Examples for overriding BaseTouchBehavior and implementing a TouchController
Apr 21st, 2021 at 7:21pm
Print Post  
In my use case, I will likely need to override BaseTouchBehavior to create a customized touch behavior implementation. This may also result in needing to create a customized TouchController as well.

I was just curious if there are any examples for overriding either of these two classes that may be helpful to learn from? Even if the examples come from the WPF, Android, or other some other version of the Diagramming library?

Just to give you an idea of the kind of behavior I am looking to implement: it is very similar to the "Pan and Modify" behavior, except for one additional point - I want to let users draw links by doing the following steps:

1. Pressing/tapping/clicking on an AnchorPoint begins drawing a new link from that point.
2. Pressing/tapping/clicking on another AnchorPoint completes the new link, terminating it at that point.
3. As an alternative to number 2 above: If the user holds the finger down and drags, the link is drawn as the user drags his finger.

Some of these behaviors are similar to the "DrawLinks" behavior, but not identical.

Anyway: I'm just curious if there are examples to learn from regarding overriding the classes I mentioned above (BaseTouchBehavior and TouchController). Thanks!
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Examples for overriding BaseTouchBehavior and implementing a TouchController
Reply #1 - Apr 22nd, 2021 at 10:08am
Print Post  
Hi,

The interaction system works in a way, such that interactions actually start after the user performs a drag over a small distance and not on a tap/click. So creation of links by clicking the start and end anchor points by implementing a custom behavior can't be accomplished without bypassing the system and handling the lower level touch events on the Diagram object.

That said, it is easy enough to achieve the desired behavior where links are created with dragging (option 3). A way to do it is to sub-class the PanAndModify class and in a SelectController method override, perform hit-testing on a node's AnchorPattern points collection to identify a pointed anchor. When an anchor is identified, create a custom touch controller, that will handle the incoming interactions - updating the link position on moving, and performing hit-test on the destination node's anchors to complete the interaction.

We've created a small sample application that demonstrates this approach and it can be downloaded here: https://mindfusion.eu/_samples/CustomizeBehavior.zip.

Regards,
Lyubo
MindFusion
  
Back to top
 
IP Logged
 
dpru2
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 19
Joined: Feb 2nd, 2021
Re: Examples for overriding BaseTouchBehavior and implementing a TouchController
Reply #2 - Apr 26th, 2021 at 7:42pm
Print Post  
Thank you for that example! It was very helpful to see how to interact with the API to accomplish that goal.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint