Page Index Toggle Pages: [1] 2 3  Send TopicPrint
Very Hot Topic (More than 25 Replies) Node Edit Mode through F2 ! (Read 15075 times)
Kannan Thirumal
Senior Member
****
Offline


I Love Mind Fusion Diagram
:-)

Posts: 270
Location: Bangalore, India
Joined: Jan 18th, 2019
Node Edit Mode through F2 !
Sep 20th, 2019 at 4:31am
Print Post  
Hi,

     By double clicking the node, the node can be made as editable. Similarly how to go to edit mode by pressing key F2 key?

Regards,
Kannan
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Node Edit Mode through F2 !
Reply #1 - Sep 20th, 2019 at 5:40am
Print Post  
Hi,

This works in my test:
Code (Javascript)
Select All
document.onkeydown = function (e)
{
    var diagram = Diagram.find('diagram');

    if (e.keyCode == 113)
    {
        if (diagram.getActiveItem())
        {
            var item = diagram.getActiveItem();
            diagram.beginEdit(item);
        }
    }
}; 



Regards,
Lyubo
MindFusion
  
Back to top
 
IP Logged
 
Kannan Thirumal
Senior Member
****
Offline


I Love Mind Fusion Diagram
:-)

Posts: 270
Location: Bangalore, India
Joined: Jan 18th, 2019
Re: Node Edit Mode through F2 !
Reply #2 - Sep 20th, 2019 at 6:36am
Print Post  
Thank you Lyubo. It works fine !  Smiley

My diagram code is expecting a Point object for beginEdit. I gave just 0,0, it still works.

diagram.beginEdit(item, new Point(0, 0));

But if I give 50, 0 also there is no difference.
  
Back to top
 
IP Logged
 
Kannan Thirumal
Senior Member
****
Offline


I Love Mind Fusion Diagram
:-)

Posts: 270
Location: Bangalore, India
Joined: Jan 18th, 2019
Re: Node Edit Mode through F2 !
Reply #3 - Oct 3rd, 2019 at 1:57pm
Print Post  
Hi,

I want to edit the shape node when I double click the node. I'm able to do this by the following code,

this.diagram.setAllowInplaceEdit(true);

But I don't want to do for composite node. For that I tried the below code,

    this.diagram.addEventListener(Event.enterInplaceEditMode, (sender, args) => {

      var element = args;

      var diagram = Diagram.find('diagram');
      if (diagram.getActiveItem()) {

        // TODO: Active item is wrongly coming as ShapeNode after clicking ShapeNode and then double clicking CompositeNode?
        var item = diagram.getActiveItem();

        //if (item instanceof CompositeNode) {
        if (!(item instanceof ShapeNode)) {
          diagram.endEdit(false);
        }
      }
    });

But the active item is wrongly coming as ShapeNode (which is having text and editable) after clicking ShapeNode and then double clicking CompositeNode?

May I know why this happens?

Regards,
Kannan
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Node Edit Mode through F2 !
Reply #4 - Oct 4th, 2019 at 5:46am
Print Post  
Hi,

ActiveItem is not guaranteed to be correct during the time this event is handled - although in my test using your sample application provided earlier, the above code works for CompositeNode too.

You should use the InplaceEditEventArgs object passed as argument to the handler method to get the item, source of the event. Calling args.getItem() from the handler gets a reference to the correct node in my test.

Regards,
Lyubo
  
Back to top
 
IP Logged
 
Kannan Thirumal
Senior Member
****
Offline


I Love Mind Fusion Diagram
:-)

Posts: 270
Location: Bangalore, India
Joined: Jan 18th, 2019
Re: Node Edit Mode through F2 !
Reply #5 - Oct 4th, 2019 at 9:15am
Print Post  
Thank you Lyubo.

I tried the below and it works,

var element = args.getItem();

But when I compare with CompositeNode like this, it returns false,

if (element instanceof CompositeNode) {

}

May I know why?
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Node Edit Mode through F2 !
Reply #6 - Oct 4th, 2019 at 9:49am
Print Post  
Hi,

Use the following instead:
Code
Select All
if(MindFusion.AbstractionLayer.isInstanceOfType(MindFusion.Diagramming.CompositeNode, element)) {

} 



Regards,
Lyubo
  
Back to top
 
IP Logged
 
Kannan Thirumal
Senior Member
****
Offline


I Love Mind Fusion Diagram
:-)

Posts: 270
Location: Bangalore, India
Joined: Jan 18th, 2019
Re: Node Edit Mode through F2 !
Reply #7 - Oct 4th, 2019 at 12:48pm
Print Post  
This works. Thank you !  Smiley
  
Back to top
 
IP Logged
 
Kannan Thirumal
Senior Member
****
Offline


I Love Mind Fusion Diagram
:-)

Posts: 270
Location: Bangalore, India
Joined: Jan 18th, 2019
Re: Node Edit Mode through F2 !
Reply #8 - Oct 25th, 2019 at 4:17am
Print Post  
Hi,

May I know how to set the max length of the edit text box (in shape node)?

For example I want to set the max length of the edit text box to 500 so that the user cannot enter more than 500 characters.

Regards,
Kannan
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3154
Joined: Oct 19th, 2005
Re: Node Edit Mode through F2 !
Reply #9 - Oct 25th, 2019 at 5:37am
Print Post  
Hi,

You can set maxLength on the textarea used for editing -

Code
Select All
diagram.addEventListener(Events.enterInplaceEditMode, function (sender, args)
{
	args.getControl().maxLength = 33;
}); 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Kannan Thirumal
Senior Member
****
Offline


I Love Mind Fusion Diagram
:-)

Posts: 270
Location: Bangalore, India
Joined: Jan 18th, 2019
Re: Node Edit Mode through F2 !
Reply #10 - Oct 30th, 2019 at 2:29pm
Print Post  
Hi,

Thanks. It works.

After entering more line of text, the node's height is not changed. I want to adjust the nodes height so that all the text is visible after entering multiple line of text. May I know how to find the height?

I tried like this but height is not coming correctly,

    this.diagram.addEventListener(Event.leaveInplaceEditMode, (sender, args) => {

      var textarea = args.getControl();
      var node = args.getItem();
      node.bounds.height = textarea.scrollHeight;
    });

Regards,
Kannan
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3154
Joined: Oct 19th, 2005
Re: Node Edit Mode through F2 !
Reply #11 - Oct 30th, 2019 at 5:57pm
Print Post  
Hi,

Try calling the node's resizeToFitText method with KeepWidth as argument.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Kannan Thirumal
Senior Member
****
Offline


I Love Mind Fusion Diagram
:-)

Posts: 270
Location: Bangalore, India
Joined: Jan 18th, 2019
Re: Node Edit Mode through F2 !
Reply #12 - Oct 31st, 2019 at 5:24am
Print Post  
Hi,

I tried the same way like below and it works.

    this.diagram.addEventListener(Event.leaveInplaceEditMode, (sender, args) => {

      var node = args.getItem() as ShapeNode;
      node.resizeToFitText(MIND.FitSize.KeepWidth);
    });

But after leaving the edit mode, it is not resizing. It is resizing on the second time. That is once again I've go to edit mode and click outside.

Regards,
Kannan
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3154
Joined: Oct 19th, 2005
Re: Node Edit Mode through F2 !
Reply #13 - Oct 31st, 2019 at 7:01am
Print Post  
Hi,

Call it from nodeTextEdited handler.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Kannan Thirumal
Senior Member
****
Offline


I Love Mind Fusion Diagram
:-)

Posts: 270
Location: Bangalore, India
Joined: Jan 18th, 2019
Re: Node Edit Mode through F2 !
Reply #14 - Oct 31st, 2019 at 7:24am
Print Post  
Yes this works, Thank you  Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 3 
Send TopicPrint