Custom mouse behavior


Hello,

I’m thinking to use goDiagram as part of an app but I have a
query about the user interface. We need to be able to set up the app so
that, to create an arrow, the user left clicks once on a node and the
arrow then remains attacted to the cursor, as the user moves it. To
connect the arrow to another node the user left clicks over it. So far
I’ve only been able to implement behaviour where by the user must hold
down the left mouse button to connect arrows. Any help on how I might
create this sort of behaviour would be appreciated.

Rich.

For interactive things like that, you need customize an existing tool or define a new one. There are some examples of this in the sample applications.
In Demo1 the RoutingLinkTool might be doing a lot more than you want, since it lets the user click anywhere they like to “route” the link, thereby augmenting a GoStroke that is shown temporarily.
When they click on valid destination port the tool actually creates a link and sets its points to be the same as temporary stroke’s points.
Additional enhancements include maintaining orthogonality if desired and being able to “undo” points that the user clicked accidentally or incorrectly.
But as I mentioned, that example tool sounds like it might be too much more than you need.
The RelationshipTool in OrgCharter is much simpler, since it just requires two clicks to be successful. Invoke it in the OrgCharter app using either F5 or the Insert | Draw Relationship menu command.
It ignores clicks that don’t pick a valid node, both for choosing the first/source node as well as the second/destination node. Since links have to connect ports, not nodes, it also chooses the closest port on the node to where the user clicks.
So I would try the RelationshipTool, and look at the more complicated RoutingLinkTool for potential customization ideas, depending on your needs.

Hi Walter,

Thanks for that - this is indeed the functionality that I require.
However I have another question now! When a link is created is with the
avoidsnodes property is there anyway of specifying how it will be
drawn. e.g Is there anywhere that I can set a property so that the the
link will minimise the number of turns, or the number of times the link
crosses another link etc.
Sorry if I have missed something obvious.
Thank you for your time.

Rich.

Regarding customizing the routing that GoLink.AvoidsNodes chooses:
No, sorry, there isn’t any way to customize that. It currently chooses a shortest route with a minimum number of turns. It ignores the paths that other links might take, but we’re considering improvements for a future release.