Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Handling ShapeNode click event in ImageMap mode (Read 5121 times)
LGK
YaBB Newbies
*
Offline



Posts: 30
Location: Boston, MA
Joined: Mar 29th, 2012
Handling ShapeNode click event in ImageMap mode
Apr 4th, 2012 at 1:41pm
Print Post  
Hi Stoyan et al. -

I'm facing another challenge. I have a ShapeNode (in 'ImageMap' mode), that contains 2 words within it (e.g. "Google" and "Bing"). Is it possible to detect what word the user has clicked on? I need to be able to handle the click that correspond to each of the words - it doesn't matter it it's client-side or server-side (e.g. when clicked on "Google" redirect to "www.google.com").

Thank you in advance!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Handling ShapeNode click event in ImageMap mode
Reply #1 - Apr 4th, 2012 at 5:17pm
Print Post  
If you need to show only a few words on their own, and not detect which word is clicked from some larger text string, there are several ways you can implement that.

E.g. you could create individual ShapeNodes to display each word, where the Hyperlink property of a node is set to the respective URL. You can optionally set these nodes Transparent property to hide their geometry and display only text, and call AttachTo to attach them to a larger node that display the shape and/or image.

Alternatively, you can show each word in a separate cell of a TableNode. Along with spanning cells, this could be useful if you need to present a survey of some kind. E.g. a large spanning cell could display a description or question, and then individual cells in another column could display individual options or answers.

If what you need is to detect which word is clicked from some larger body of text, this could probably be done if we make public some of our text format structures used to cache the text layout for each node (text layout is calculated when a node's size changes, and then text is repainted from the cached layout information).

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
LGK
YaBB Newbies
*
Offline



Posts: 30
Location: Boston, MA
Joined: Mar 29th, 2012
Re: Handling ShapeNode click event in ImageMap mode
Reply #2 - Apr 4th, 2012 at 8:23pm
Print Post  
Thank you for the quick and thorough response, Stoyan.

I've attached an example of what I would like to achieve with my ImageMap diagram. I want to have 2 "hyperlinks" in each of my nodes (e.g. "Go To Record" & "More Info"), so that when the user clicks on one or the other, (s)he will be navigated to a different location within the site.

So, it was not completely clear if I would be able to achieve this by using one of the suggested methods above:

  1.   Create individual ShapeNodes to display each word + set the Hyperlink property, make them transparent and AttachTo a larger node.
  2. Show each word in a separate cell of a TableNode (Can I set a different Hyperlink on each of the cells in a TableNode?)


Your feedback is much appreciated!
  

sample_node.jpg (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Handling ShapeNode click event in ImageMap mode
Reply #3 - Apr 5th, 2012 at 5:58am
Print Post  
Both methods should work. Implementing that with ShapeNodes should look like this:

Code
Select All
var node = diagram.Factory.CreateShapeNode(0, 0, 60, 30);
node.Text = "Node 1";

var leftLink = diagram.Factory.CreateShapeNode(0, 0, 30, 10);
leftLink.Transparent = true;
leftLink.TextColor = Color.Blue;
leftLink.Font = new Font(leftLink.Font, FontStyle.Underline);
leftLink.Text = "Go to Record";
leftLink.HyperLink = "http://lgk.com/go/1";

var rightLink = diagram.Factory.CreateShapeNode(30, 0, 30, 10);
rightLink.Transparent = true;
rightLink.TextColor = Color.Blue;
rightLink.Font = new Font(leftLink.Font, FontStyle.Underline);
rightLink.Text = "More Info";
rightLink.HyperLink = "http://lgk.com/info/1";

// uncomment this if users will be able to move nodes
// leftLink.AttachTo(node, AttachToNode.TopLeft);
// rightLink.AttachTo(node, AttachToNode.TopLeft);
 



Or using a TableNode, set CaptionHeight to 0, RowCount and ColumnCount to 2, table.Rows[1].Height to 30, table[0,1].ColumnSpan to 2, table.CellFrameStyle to None. Now you can display your main text in the table[0,1] cell, and the hyperlinks in table[0,0] and table[1,0].

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
LGK
YaBB Newbies
*
Offline



Posts: 30
Location: Boston, MA
Joined: Mar 29th, 2012
Re: Handling ShapeNode click event in ImageMap mode
Reply #4 - Apr 5th, 2012 at 9:31pm
Print Post  
This is brilliant - thank you!

I used the TableNode object to better organize my content (due to its grid structure). And I got my links to work!! But, now I'm having a few UI-related issues. Please refer to the attached screenshots:

  • TableNodeDiagram.jpg - a portion of the graph rendered via a TableNode.
  • ShapeNodeDiagram.jpg - same portion of the graph rendered via a ShapeNode.

I have 2 questions:

  1. How do I remove the "Table" text that appears (by default) at the top in each of the nodes?
  2. The links between the nodes render quite messy/unreadable - how could I get them to appear more clean and organized as in the graph built with ShapeNode's?

Thanks again, Stoyan!
  

TableNodeDiagram.jpg (Attachment deleted)
ShapeNodeDiagram.jpg (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Handling ShapeNode click event in ImageMap mode
Reply #5 - Apr 6th, 2012 at 6:10am
Print Post  
Hi,

Set Caption to an empty string to remove that text.

When using TableNodes, a link's target can be either the whole node (as with ShapeNodes) or an individual row within the table. I think in this case the links connect to rows when you create them, and remain connected to the same rows after arranging the diagram.

You could try setting TableNode.ConnectionStyle = Table to prevent row connections before links are created, or set OriginIndex/DestinationIndex to -1 for all links before applying a layout algorithm.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
LGK
YaBB Newbies
*
Offline



Posts: 30
Location: Boston, MA
Joined: Mar 29th, 2012
Re: Handling ShapeNode click event in ImageMap mode
Reply #6 - Apr 6th, 2012 at 2:18pm
Print Post  
Hi Stoyan - after making your recommendations, the resulting graph looks perfect !!!

Thanks for taking the time to provide me with this invaluable feedback! Best regards.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint