AccessibleSelection (Enumeración)
Actualización: noviembre 2007
Especifica cómo se selecciona o cómo recibe el foco un objeto accesible.
Esta enumeración tiene un atributo FlagsAttribute que permite una combinación bit a bit de los valores de miembro.
Espacio de nombres: System.Windows.FormsEnsamblado: System.Windows.Forms (en System.Windows.Forms.dll)
| Nombre de miembro | Descripción | |
|---|---|---|
| None | La selección o foco de un objeto no sufre ningún cambio. | |
| TakeFocus | Asigna el foco a un objeto y lo convierte en el delimitador, que es el punto de inicio de la selección. Se puede combinar con TakeSelection, ExtendSelection, AddSelection o RemoveSelection. | |
| TakeSelection | Selecciona el objeto y anula la selección del resto de objetos del contenedor. | |
| ExtendSelection | Selecciona todos los objetos entre el delimitador y el objeto seleccionado. | |
| AddSelection | Agrega el objeto a la selección. | |
| RemoveSelection | Quita el objeto de la selección. |
El objeto que tiene el foco es el que recibe acciones del teclado. El objeto con el foco de teclado es la ventana activa o un objeto secundario de dicha ventana. Un objeto seleccionado se marca para que participe en algún tipo de operación de agrupamiento.
AccessibleObject.Select utiliza esta enumeración.
Para obtener información adicional sobre la aplicación de accesibilidad, busque "Microsoft Active Accessibility" en la Microsoft Developer Network (MSDN) Library.
En el siguiente ejemplo de código se muestra la creación de un control de gráfico con reconocimiento de accesibilidad mediante las clases AccessibleObject y Control.ControlAccessibleObject con el fin de exponer información accesible. El control dibuja dos curvas acompañadas de una leyenda. La clase ChartControlAccessibleObject, que se deriva de ControlAccessibleObject, se utiliza en el método CreateAccessibilityInstance a fin de proporcionar información personalizada accesible para el control de gráfico. Dado que la leyenda del gráfico no es en realidad un control basado en Control, sino que la dibuja el control de gráfico, no contiene ningún tipo de información accesible integrada. Debido a esto, la clase ChartControlAccessibleObject reemplaza el método GetChild para devolver CurveLegendAccessibleObject que representa la información accesible de cada parte de la leyenda. Cuando este control se utiliza en una aplicación con reconocimiento de accesibilidad, el control puede proporcionar la información accesible que sea necesaria.
En este ejemplo se muestra el uso de la enumeración AccessibleSelection con el método Select. Para obtener el ejemplo completo del código, vea la información general de la clase AccessibleObject.
// Inner class ChartControlAccessibleObject represents accessible information associated with the ChartControl. // The ChartControlAccessibleObject is returned in the ChartControl.CreateAccessibilityInstance override. public class ChartControlAccessibleObject : ControlAccessibleObject { ChartControl chartControl; public ChartControlAccessibleObject(ChartControl ctrl) : base(ctrl) { chartControl = ctrl; } // Gets the role for the Chart. This is used by accessibility programs. public override AccessibleRole Role { get { return AccessibleRole.Chart; } } // Gets the state for the Chart. This is used by accessibility programs. public override AccessibleStates State { get { return AccessibleStates.ReadOnly; } } // The CurveLegend objects are "child" controls in terms of accessibility so // return the number of ChartLengend objects. public override int GetChildCount() { return chartControl.Legends.Length; } // Gets the Accessibility object of the child CurveLegend idetified by index. public override AccessibleObject GetChild(int index) { if (index >= 0 && index < chartControl.Legends.Length) { return chartControl.Legends[index].AccessibilityObject; } return null; } // Helper function that is used by the CurveLegend's accessibility object // to navigate between sibiling controls. Specifically, this function is used in // the CurveLegend.CurveLegendAccessibleObject.Navigate function. internal AccessibleObject NavigateFromChild(CurveLegend.CurveLegendAccessibleObject child, AccessibleNavigation navdir) { switch(navdir) { case AccessibleNavigation.Down: case AccessibleNavigation.Next: return GetChild(child.ID + 1); case AccessibleNavigation.Up: case AccessibleNavigation.Previous: return GetChild(child.ID - 1); } return null; } // Helper function that is used by the CurveLegend's accessibility object // to select a specific CurveLegend control. Specifically, this function is used // in the CurveLegend.CurveLegendAccessibleObject.Select function. internal void SelectChild(CurveLegend.CurveLegendAccessibleObject child, AccessibleSelection selection) { int childID = child.ID; // Determine which selection action should occur, based on the // AccessibleSelection value. if ((selection & AccessibleSelection.TakeSelection) != 0) { for(int i = 0; i < chartControl.Legends.Length; i++) { if (i == childID) { chartControl.Legends[i].Selected = true; } else { chartControl.Legends[i].Selected = false; } } // AccessibleSelection.AddSelection means that the CurveLegend will be selected. if ((selection & AccessibleSelection.AddSelection) != 0) { chartControl.Legends[childID].Selected = true; } // AccessibleSelection.AddSelection means that the CurveLegend will be unselected. if ((selection & AccessibleSelection.RemoveSelection) != 0) { chartControl.Legends[childID].Selected = false; } } } }
// Inner class ChartControlAccessibleObject represents accessible
// information associated with the ChartControl.
// The ChartControlAccessibleObject is returned in the
// ChartControl.CreateAccessibilityInstance override.
public static class ChartControlAccessibleObject
extends ControlAccessibleObject
{
private ChartControl chartControl;
public ChartControlAccessibleObject(ChartControl ctrl)
{
super(ctrl);
chartControl = ctrl;
} //ChartControlAccessibleObject
// Gets the role for the Chart. This is used by accessibility programs.
/** @property
*/
public AccessibleRole get_Role()
{
return AccessibleRole.Chart;
} //get_Role
// Gets the state for the Chart. This is used by accessibility programs.
/** @property
*/
public AccessibleStates get_State()
{
return AccessibleStates.ReadOnly;
} //get_State
// The CurveLegend objects are "child" controls in terms of
// accessibility so return the number of ChartLengend objects.
public int GetChildCount()
{
return chartControl.get_Legends().get_Length();
} //GetChildCount
// Gets the Accessibility object of the child CurveLegend
// idetified by index.
public AccessibleObject GetChild(int index)
{
if (index >= 0 && index < chartControl.get_Legends().get_Length()) {
return chartControl.get_Legends()[index].
get_AccessibilityObject();
}
return null;
} //GetChild
// Helper function that is used by the CurveLegend's accessibility
// object to navigate between sibiling controls.
// Specifically, this function is used in
// the CurveLegend.CurveLegendAccessibleObject.Navigate function.
AccessibleObject NavigateFromChild(
CurveLegend.CurveLegendAccessibleObject child,
AccessibleNavigation navDir)
{
if (navDir.Equals(AccessibleNavigation.Down)
|| navDir.Equals(AccessibleNavigation.Next)) {
return GetChild(child.get_ID() + 1);
}
else {
if (navDir.Equals(AccessibleNavigation.Up)
|| navDir.Equals(AccessibleNavigation.Previous)) {
return GetChild(child.get_ID() - 1);
}
}
return null;
} //NavigateFromChild
// Helper function that is used by the CurveLegend's accessibility
// object to select a specific CurveLegend control.
// Specifically, this function is used
// in the CurveLegend.CurveLegendAccessibleObject.Select function.
public void SelectChild(CurveLegend.CurveLegendAccessibleObject child,
AccessibleSelection selection)
{
int childID = child.get_ID();
// Determine which selection action should occur, based on the
// AccessibleSelection value.
if (Convert.ToInt32(selection & AccessibleSelection.TakeSelection)
!= 0) {
for (int i = 0; i < chartControl.get_Legends().get_Length();
i++) {
if (i == childID) {
((CurveLegend)chartControl.get_Legends().get_Item(i)).
set_Selected(true);
}
else {
((CurveLegend)chartControl.get_Legends().get_Item(i)).
set_Selected(false);
}
}
// AccessibleSelection.AddSelection means that the CurveLegend
// will be selected.
if (Convert.ToInt32(selection & AccessibleSelection.AddSelection)
!= 0) {
((CurveLegend)chartControl.get_Legends().get_Item(childID)).
set_Selected(true);
}
// AccessibleSelection.AddSelection means that the CurveLegend
// will be unselected.
if (Convert.ToInt32(selection &
AccessibleSelection.RemoveSelection) != 0) {
((CurveLegend)chartControl.get_Legends().get_Item(childID)).
set_Selected(false);
}
}
} //SelectChild
} //ChartControlAccessibleObject
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.