Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Can I intercept node delete? (Read 1869 times)
brianh
YaBB Newbies
*
Offline



Posts: 30
Joined: Jul 1st, 2008
Can I intercept node delete?
Jul 8th, 2008 at 11:02am
Print Post  
Hi,

I want to ask the user for confirmation before deleting a node, but at the moment, if the user selects a node and hits the delete key it gets deleted without warning.

Is there any way to hook into this process so I can confirm or cancel the operation depending on the users response?

Also, when a node is deleted, the Dipose() method does not seem to be getting called! :S  I have worked around this by overriding OnRemove() and calling it myself but I would have thought it should be called automatically when the node is deleted.  Is this a bug or am I missing something?

Thanks.

Brian
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Can I intercept node delete?
Reply #1 - Jul 8th, 2008 at 11:40am
Print Post  
Hi,

You could handle NodeDeleting and set args.Cancel = true, or otherwise set DiagamView.DelKeyAction = None and handle the key-down event for Del yourself.

The control calls OnRemove when an item is removed from the diagram, but it might appear again after undo/redo operations, so it might not be safe to call Dispose from there. When there are no references to the item even in the undo/redo queue, the FreeResources method is called. The control does not call DiagramItem.Dispose automatically, because for example you might be moving it to a different Diagram, or need to keep a reference to the item for some other reason.

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



Posts: 30
Joined: Jul 1st, 2008
Re: Can I intercept node delete?
Reply #2 - Jul 8th, 2008 at 1:10pm
Print Post  
Hi Stoyan,

That has been very helpful. Smiley

I do still have a problem though, if I make one node a child of another by using AttachTo(), and I have the SubordinateGroup.AutoDeleteItems set to true, then if I select the parent node and hit delete they are both deleted (as expected), but if I select BOTH nodes and hit delete I get an exception. Sad

I assume the problem is due to the fact that deleting the first node causes it's child to be deleted too, and so when an attempt is then made to delete the second selected node it no longer exists!

Is this a bug?

Thanks.

Brian
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Can I intercept node delete?
Reply #3 - Jul 8th, 2008 at 2:34pm
Print Post  
Hi Brian,

Yes, it’s bug. Until we fix it, you can set Locked = true for the button node to prevent its selection.

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint