Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Proper way to delete a node (Read 2568 times)
pwdparis
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 15
Joined: Jan 18th, 2010
Proper way to delete a node
Feb 11th, 2010 at 6:11pm
Print Post  
Have not been able to delete a node using the keyboard's delete button. We make sure that the diagram is focused, but the keydown event never seems to fire. Could you give me very specific directions on how to achieve this?

Thanks,

Mark
Goolara, LLC
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Proper way to delete a node
Reply #1 - Feb 11th, 2010 at 7:40pm
Print Post  
Try setting the keyboard focus in response to some mouse event, e.g.

Code
Select All
private void Diagram_NodeSelected(object sender, NodeEventArgs e)
{
	diagram.Focus();
} 



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


I love YaBB 1G - SP1!

Posts: 15
Joined: Jan 18th, 2010
Re: Proper way to delete a node
Reply #2 - Feb 12th, 2010 at 1:03pm
Print Post  
Stoyan,

I tried this:

private void diagram1_NodeSelected(object sender, MindFusion.Diagramming.Silverlight.NodeEventArgs e)
{
diagram1.Focus();

e.Node.KeyDown += this.deleteNode;
}

However, the "deletedNode" event never gets fired.

All help appreciated,

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Proper way to delete a node
Reply #3 - Feb 12th, 2010 at 2:57pm
Print Post  
Hi Mark,

Handle the diagram's KeyDown event and it should work.

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


I love YaBB 1G - SP1!

Posts: 15
Joined: Jan 18th, 2010
Re: Proper way to delete a node
Reply #4 - Feb 16th, 2010 at 8:38pm
Print Post  
Stoyan,

Thank you very much. We're getting the key down event fired as expected now.

However, we have a further dilemma. Our diagram nodes have a HandlesStyle of MoveOnly, which gives us the expected frame around the node when a user mouses over a node. However, a user can select a different node with a left-button click, giving us two nodes that appear selected. (Hitting the delete key deletes the expected node, the selected one as opposed to the mouse-overed one, which is what we want.) Given that two items appearing selected may confuse the user, can we somehow turn off the mouse-over behavior for the node? We still want to use the MoveOnly HandlesStyle and we also want to be able to support deleting multiple items as well.

Thanks again,

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Proper way to delete a node
Reply #5 - Feb 17th, 2010 at 9:13am
Print Post  
Hi Mark,

Yes, you can turn it off by setting diagram.ModificationStart = SelectedOnly. However this will prevent users from moving items with a single mouse click. If you need that too, you might have to use a custom BehaviorBase -derived class. Another way to implement this is to dynamically change ModificationStart in response to the SelectionChange event, depending on whether there are any selected nodes at that point.

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


I love YaBB 1G - SP1!

Posts: 15
Joined: Jan 18th, 2010
Re: Proper way to delete a node
Reply #6 - Feb 17th, 2010 at 3:07pm
Print Post  
Stoyo,

I like the latter idea. I will give it a shot and let you know how it turns out.

Thanks,

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