how to get graphic for focused area

938
10
02-28-2011 10:26 AM
ThaoNguyen
New Contributor II
When tabbing on map, I can see the focus (dotted rectangle) moves between areas. I want to implement an event handler to handle key down event so that when I tab thru states for instance, and hit Ctrl + Space, I select that graphic.  How do I get the gragphic for that focused area?

Thanks!
0 Kudos
10 Replies
ThaoNguyen
New Contributor II
When tabbing on map, I can see the focus (dotted rectangle) moves between areas. I want to implement an event handler to handle key down event so that when I tab thru states for instance, and hit Ctrl + Space, I select that graphic.  How do I get the gragphic for that focused area?

Thanks!


Is there any answer to this question?  Or there is no way to know the graphic associated with the focus?  Thanks!
0 Kudos
JenniferNery
Esri Regular Contributor
I don't think this is possible, unless your symbol template includes controls. TabIndex is a property of Control. Shapes, like Rectangle, do not have this property.

You can try this SDK sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ElementLayer. Notice that even in an Element layer, you can only tab through some features (button and textbox).
0 Kudos
ThaoNguyen
New Contributor II
I don't think this is possible, unless your symbol template includes controls. TabIndex is a property of Control. Shapes, like Rectangle, do not have this property.

You can try this SDK sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ElementLayer. Notice that even in an Element layer, you can only tab through some features (button and textbox).


I didn't implement the tabing function to my features.  I just noticed that I was able to tab through my features added to my graphic layer.  I just want to get the graphic where the tab stops.
0 Kudos
ThaoNguyen
New Contributor II
I want to make sure that my question is clear this time.
Attached is my map with a bounding box (in black) for Mountain region.  That is the result I get when I press tab key.  The bounding box moves to each feature in the order I add Graphic objects to the graphic map layer.  I can also move the bounding box through features by pressing Ctrl and arrow keys.  So, it must be something provided by Arcgis.  It is nice to have this fuction, but now, I need to get the feature where the bounding box is.  Can I do that?

If there is no way, will the feature be considered next release?

Thanks!
0 Kudos
JenniferNery
Esri Regular Contributor
Oh you must be using WPF! It was the only way I could get the graphics to get focus through tab event. Unfortunately, this seems to be a bug. The graphics should not be receiving focus through tab event. This might be something that needs to go away in the future.
0 Kudos
ThaoNguyen
New Contributor II
Oh you must be using WPF! It was the only way I could get the graphics to get focus through tab event. Unfortunately, this seems to be a bug. The graphics should not be receiving focus through tab event. This might be something that needs to go away in the future.


Yes, I'm using WPF.
OK, it's good to know the answer so that we decide what to do.
Thanks again!
0 Kudos
ThaoNguyen
New Contributor II
Yes, I'm using WPF.
OK, it's good to know the answer so that we decide what to do.
Thanks again!


Sorry, I think again.  I think that an event handler was implemented for Graphic class because I am able to press Ctrl + arrow keys to move the bounding box, so it may not be a bug as you said :).  Would you please double check with the development team about this?  This is really important to us!
0 Kudos
JenniferNery
Esri Regular Contributor
I actually showed this to our Dev Lead yesterday and he thinks it's a bug. While you seem to be able to navigate through the graphics through tabbing or CTRL + Arrow keys, you are only getting the graphic element which is a control that is associated to the graphic.

To demonstrate that this tab property is inherited from Control. You can try the following sample in your WPF application. Notice that you can tab through control items unless you set their IsTabStop to false.
 <StackPanel>
  <StackPanel.Resources>
   <ControlTemplate x:Key="MyEllipse" TargetType="{x:Type Control}">    
     <Ellipse Height="50" Width="50" Fill="Red"/>
   </ControlTemplate>
   <ControlTemplate x:Key="MyRectangle" TargetType="{x:Type Control}">
    <Rectangle Height="50" Width="50" Fill="Blue"/>
   </ControlTemplate>
  </StackPanel.Resources>
   <Button Content="My Button"/>
  <ListBox>
   <ListBox.Items>
    <sys:String>item 1</sys:String>
    <sys:String>item 2</sys:String>
    <sys:String>item 3</sys:String>
   </ListBox.Items>
   <ListBox.ItemTemplate>
    <DataTemplate>
     <TextBlock Text="{Binding}"/>
    </DataTemplate>
   </ListBox.ItemTemplate>
  </ListBox>
  <Control Template="{StaticResource MyEllipse}"/>
  <Control Template="{StaticResource MyRectangle}"/>  
 </StackPanel>
0 Kudos
ThaoNguyen
New Contributor II
I actually showed this to our Dev Lead yesterday and he thinks it's a bug. While you seem to be able to navigate through the graphics through tabbing or CTRL + Arrow keys, you are only getting the graphic element which is a control that is associated to the graphic.

To demonstrate that this tab property is inherited from Control. You can try the following sample in your WPF application. Notice that you can tab through control items unless you set their IsTabStop to false.
 <StackPanel>
  <StackPanel.Resources>
   <ControlTemplate x:Key="MyEllipse" TargetType="{x:Type Control}">    
     <Ellipse Height="50" Width="50" Fill="Red"/>
   </ControlTemplate>
   <ControlTemplate x:Key="MyRectangle" TargetType="{x:Type Control}">
    <Rectangle Height="50" Width="50" Fill="Blue"/>
   </ControlTemplate>
  </StackPanel.Resources>
   <Button Content="My Button"/>
  <ListBox>
   <ListBox.Items>
    <sys:String>item 1</sys:String>
    <sys:String>item 2</sys:String>
    <sys:String>item 3</sys:String>
   </ListBox.Items>
   <ListBox.ItemTemplate>
    <DataTemplate>
     <TextBlock Text="{Binding}"/>
    </DataTemplate>
   </ListBox.ItemTemplate>
  </ListBox>
  <Control Template="{StaticResource MyEllipse}"/>
  <Control Template="{StaticResource MyRectangle}"/>  
 </StackPanel>


Thank you!  So, Graphic class has IsTabStop=true by default and it should be set to false?
I think it is a nice feature to have though.  If Arcgis can provide a function to grab graphic of the focused area, it would be helpful to consumers like us.
0 Kudos