Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic UIElement Line and Mouse button click (Read 1711 times)
solisgsandc
YaBB Newbies
*
Offline



Posts: 40
Joined: Dec 18th, 2009
UIElement Line and Mouse button click
Feb 11th, 2010 at 5:34pm
Print Post  
When I use the mouse button click on the line, it does not seem to pick it up right away. I have to be right on top of the line which could be very thin. Is there a way to increase the hit distance on this UIElement?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: UIElement Line and Mouse button click
Reply #1 - Feb 11th, 2010 at 7:29pm
Print Post  
If by line you mean a DiagramLink, try setting a larger LinkHitDistance value. There is no such property for nodes, so if that's a hosted control that contains just one line you might need to modify to control to add some margin around the line.
  
Back to top
 
IP Logged
 
solisgsandc
YaBB Newbies
*
Offline



Posts: 40
Joined: Dec 18th, 2009
Re: UIElement Line and Mouse button click
Reply #2 - Feb 11th, 2010 at 7:43pm
Print Post  
The Line UIElement is hosted inside a diagramNodeAdapter. Can you please send me some code about how to add some margin?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: UIElement Line and Mouse button click
Reply #3 - Feb 11th, 2010 at 9:20pm
Print Post  
My idea was to do something like this:

Code
Select All
var line = new Line();
line.Stroke = new SolidColorBrush(Colors.Black);
line.X1 = 5; line.Y1 = 10;
line.X2 = 55; line.Y2 = 10;
line.Width = 60;
line.Height = 20;
diagram.Nodes.Add(line); 



but it doesn't work... It seems WPF hit testing is successful only if the mouse pointer is over a painted pixel of the UIElement.

Instead, you could handle the Clicked event and use the GetNodeAt(threshold) method to find a nearby line:

Code
Select All
private void OnDiagramClicked(object sender, DiagramEventArgs e)
{
	var node = diagram.GetNodeAt(e.MousePosition, 10) as DiagramNodeAdapter;
	if (node != null && node.UIElement is Line)
		diagram.ActiveItem = node;
} 



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