Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Tab index \ Keyboard Navigation. (Read 4487 times)
maor
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 79
Joined: Mar 24th, 2009
Tab index \ Keyboard Navigation.
Apr 6th, 2009 at 9:36am
Print Post  
Hi,

1.I tried to set tabIndex on the shapes in my diagram:

shape.TabIndex = i++;

shape.TabNavigation = KeyboardNavigationMode.Cycle;

and its not succeed..

2. there is any way to enable shapes navigation with the keyboard (right,left,up,down)?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Tab index \ Keyboard Navigation.
Reply #1 - Apr 6th, 2009 at 12:43pm
Print Post  
Do you need TAB to select a shape and the arrow keys to move it?
  
Back to top
 
IP Logged
 
maor
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 79
Joined: Mar 24th, 2009
Re: Tab index \ Keyboard Navigation.
Reply #2 - Apr 6th, 2009 at 12:44pm
Print Post  
yes.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Tab index \ Keyboard Navigation.
Reply #3 - Apr 7th, 2009 at 11:55am
Print Post  
Tabbing could be done like this:

Code
Select All
private void diagram_KeyDown(object sender, KeyEventArgs e)
{
	if (e.Key == Key.Tab)
	{
		if (diagram.ActiveItem != null)
		{
			if (diagram.ActiveItem is DiagramNode)
			{
				SelectNearestRightNode(diagram.ActiveItem as DiagramNode);
			}
		}
		else
		{
			if (diagram.Nodes.Count > 0)
				diagram.Nodes[0].Selected = true;
		}
	}
}

public void SelectNearestRightNode(DiagramNode selectedNode)
{
	DiagramNode nextNode = null;
	double currDist = double.MaxValue;
	foreach (DiagramNode node in diagram.Nodes)
	{
		if (node.Equals(selectedNode))
			continue;

		double dist = node.Bounds.X - selectedNode.Bounds.X;
		if (dist > 0 && dist < currDist)
		{
			nextNode = node;
			currDist = dist;
		}
	}

	if (nextNode != null)
	{
		diagram.Selection.Clear();
		nextNode.Selected = true;
	}
}
 



Or you might get the index of the ActiveItem in the Diagram.Items collection and select the next item. The arrow keys are intercepted by the ScrollViewer and don't reach the diagram_KeyDown handler. If you want to use them, you will have to add a KeyDown handler higher in the visual tree, to the ScrollViewer or the panel that contains it.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Tab index \ Keyboard Navigation.
Reply #4 - Apr 7th, 2009 at 12:16pm
Print Post  
The arrow keys seem to work too, if you call the Diagram.Focus() method. You could do that from the MouseDown handler.
  
Back to top
 
IP Logged
 
maor
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 79
Joined: Mar 24th, 2009
Re: Tab index \ Keyboard Navigation.
Reply #5 - Apr 7th, 2009 at 12:19pm
Print Post  
Hi Stoyo,

Thanks for the answer!

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