Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Disable Mouse events (Read 4333 times)
RJ
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 27
Joined: Sep 4th, 2015
Disable Mouse events
Sep 23rd, 2015 at 5:20pm
Print Post  
I would like to disable mouse events on the diagram and be able to drag/move the nodes by clicking on them and edit text be double clicking on the nodes.

I tried the Event handling and set the Diagram Behavior to nothing, but moving the node doesnt work with Click event handler.
Here is the code for reference
Code (Javascript)
Select All
diagram = AbstractionLayer.createControl(Diagram, null, null, null, $("#diagram")[0]);

      diagram.setCustomNodeType(OrgChartNode);
      diagram.setBehavior(Behavior.SelectOnly);

      // enable undo/redo support
      diagram.setUndoEnabled(true);

      diagram.addEventListener(Events.nodeCreated, onNodeCreated);
      diagram.addEventListener(Events.linkCreated, onLinkCreated);
      diagram.addEventListener(Events.nodeDoubleClicked, onNodeDoubleClicked);
      diagram.addEventListener(Events.nodeClicked, onNodeClicked);




function onNodeCreated(sender, args) {
    var node = args.getNode();
    //node.setHandlesStyle(MindFusion.Diagramming.HandlesStyle.MoveOnly);
    // let user enter text immediately
    //diagram.beginEdit(node);
  }

  function onNodeClicked(sender, args) {
    var node = args.getNode();

//diagram.handleBrush = '#4488CC';
    //node.setSelected(true);
    // let user enter text immediately
    //diagram.setBehavior(Behavior.Pan);
    //node.setEnabledHandles(MindFusion.Diagramming.AdjustmentHandles.Move);
    node.setHandlesStyle(MindFusion.Diagramming.HandlesStyle.MoveOnly);
  }

  function onNodeDoubleClicked(sender, args) {
    var node = args.getNode();

    // let user enter text immediately
    diagram.beginEdit(node);
  }





 



Could you please help.

Thanks,
Raji
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Disable Mouse events
Reply #1 - Sep 23rd, 2015 at 5:25pm
Print Post  
If you mean you want to disable drawing new nodes on the canvas but only allow users to move existing ones, set Behavior to Modify instead of SelectOnly.
  
Back to top
 
IP Logged
 
RJ
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 27
Joined: Sep 4th, 2015
Re: Disable Mouse events
Reply #2 - Sep 23rd, 2015 at 5:37pm
Print Post  
That did the trick. Now I want to able to draw links after user clicks on a button and starts clicking on the node - but when i click on the node it only moves now and doesnt let me draw a link.

Thanks,
Raji
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Disable Mouse events
Reply #3 - Sep 23rd, 2015 at 5:48pm
Print Post  
try calling diagram.setBehavior(Behavior.DrawLinks) from that button's click handler.
  
Back to top
 
IP Logged
 
RJ
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 27
Joined: Sep 4th, 2015
Re: Disable Mouse events
Reply #4 - Sep 23rd, 2015 at 6:18pm
Print Post  
That is what i currently do. But it is very difficult to draw the link. Should i remove all the handleStyles on the nodes before i enable the DrawLinks Behavior?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Disable Mouse events
Reply #5 - Sep 23rd, 2015 at 7:40pm
Print Post  
It could be difficult for smaller nodes if they are selected, as modification handles are hit-tested with higher priority than draw-link gesture then. You could clear the selection state of nodes before entering draw-links mode, or try a different HandlesStyle (DiagramNode.setHandlesStyle method).

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint