Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Change Default Link Properties Using JavaScript (Read 2861 times)
Megan1717
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 39
Joined: Jun 20th, 2016
Change Default Link Properties Using JavaScript
Jul 7th, 2016 at 3:22pm
Print Post  
Hello again,

I have yet another question. I would like to change the default pen, brush, headshape, etc. for new links using JavaScript. I've tried a couple variations of the following:
Code (Javascript)
Select All
   function onSelect() {
        var diagram = MindFusion.Diagramming.Diagram.find("diagramView");
        diagram.setLinkHeadShapeSize(3);
        diagram.setLinkHeadShape('Triangle');
        diagram.setLinkPen("#555");
        diagram.setLinkBrush({ type: 'SolidBrush', color: 'red' });
    } 



None of these properties seem to change anything, so I'm clearly doing something wrong. I also tried using a theme in server-side, which also did nothing. I would prefer to use JavaScript and avoid the server call if possible.

Thanks once again.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Change Default Link Properties Using JavaScript
Reply #1 - Jul 7th, 2016 at 4:44pm
Print Post  
Hi,

It seems LinkPen and LinkBrush properties are not used anymore by default, and the compiler will give you obsolete warning if you set them from server side. You can still make this work by setting the useStyles flag to false -

Code
Select All
MindFusion.Diagramming.DiagramLink.useStyles = false;
diagram.setLinkHeadShapeSize(3);
diagram.setLinkHeadShape('Triangle');
diagram.setLinkPen("#555");
diagram.setLinkBrush({ type: 'SolidBrush', color: 'red' }); 



Alternatively you could set the link's own Stroke and Brush properties from InitializeLink event handler, or set defaults through a theme.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Megan1717
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 39
Joined: Jun 20th, 2016
Re: Change Default Link Properties Using JavaScript
Reply #2 - Jul 7th, 2016 at 5:08pm
Print Post  
Works perfectly. Thanks very much!!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint