Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Reagarding Hyperlink (Read 1493 times)
Shafi
Full Member
***
Offline


I Love MindFusion!

Posts: 109
Joined: Nov 8th, 2016
Reagarding Hyperlink
Dec 13th, 2017 at 6:03am
Print Post  
Hi

We have custom made container node. In which there are text images and we need to make text as one hyperlink and images as another hyperlink. We are making this node using overriding UpdateVisuals.

I tried using setHyperLink api provided in mindfusion library, but its not redirecting.
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Reagarding Hyperlink
Reply #1 - Dec 13th, 2017 at 8:44am
Print Post  
Hi,

Inside your UpdateVisuals override, you can cache the bounds of the the text and image containers, for example in the Tag property. Next, you can hittest for them from a NodeClicked event handler and open a hyperlink in response.

Code (Javascript)
Select All
function onUpdateVisuals(item: MindFusion.Diagramming.DiagramItem): void
{
    // ...

    item.setTag({ "textBounds": nodeTextRect, "imageBounds": imageRect });
}

// ...

function contains(rect: MindFusion.Drawing.Rect, point: MindFusion.Drawing.Point)
{
    return rect.x <= point.x && point.x <= rect.x + rect.width &&
        rect.y <= point.y && point.y <= rect.y + rect.height;
}

diagram.addEventListener(MindFusion.Diagramming.Events.nodeClicked, (sender, args) =>
{
    const node = args.getNode();
    if (node.getTag())
    {
        let pt = args.getMousePosition() as MindFusion.Drawing.Point;
        let textBounds = node.getTag().textBounds as Rect;
        let imageBounds = node.getTag().imageBounds as Rect;
        if (contains(textBounds, pt))
            window.open("<textUrl>");
        else if (contains(imageBounds, pt))
            window.open("<imageUrl>");
    }

    // ...
}); 



Regards,
Lyubo
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint