AccessibleSelection, énumération
Mise à jour : novembre 2007
Spécifie la façon dont un objet accessible est sélectionné ou reçoit le focus.
Cette énumération possède un attribut FlagsAttribute qui permet la combinaison d'opérations de bits de ses valeurs de membres.
Espace de noms : System.Windows.FormsAssembly : System.Windows.Forms (dans System.Windows.Forms.dll)
| Nom de membre | Description | |
|---|---|---|
| None | La sélection ou le focus d'un objet est inchangé. | |
| TakeFocus | Assigne le focus à un objet et celui-ci devient l'ancre, qui est le point de départ de la sélection. Peut être combiné avec TakeSelection, ExtendSelection, AddSelection ou RemoveSelection. | |
| TakeSelection | Sélectionne l'objet et désélectionne tous les autres objets dans le conteneur. | |
| ExtendSelection | Sélectionne tous les objets entre l'ancre et l'objet sélectionné. | |
| AddSelection | Ajoute l'objet à la sélection. | |
| RemoveSelection | Enlève l'objet de la sélection. |
Un objet ayant le focus est l'objet qui reçoit l'entrée du clavier. L'objet ayant le focus clavier est la fenêtre active ou un objet enfant de la fenêtre active. Un objet sélectionné est marqué pour participer à une opération de type groupé.
Cette énumération est utilisée par AccessibleObject.Select.
Pour plus d'informations sur l'application d'accessibilité, recherchez la rubrique « Microsoft Active Accessibility » dans MSDN Library (Microsoft Developer Network).
L'exemple de code suivant illustre la création d'un contrôle graphique prenant en charge l'accessibilité, en utilisant les classes AccessibleObject et Control.ControlAccessibleObject pour exposer des informations accessibles. Le contrôle trace deux courbes en plus d'une légende. La classe ChartControlAccessibleObject, qui dérive de ControlAccessibleObject, est utilisée dans la méthode CreateAccessibilityInstance pour fournir des informations accessibles personnalisées au contrôle graphique. Dans la mesure où la légende du graphique n'est pas un contrôle réel basé sur Control, et qu'elle est plutôt dessinée par le contrôle graphique, elle ne contient pas d'informations accessibles intégrées. De ce fait, la classe ChartControlAccessibleObject substitue la méthode GetChild pour retourner CurveLegendAccessibleObject, qui représente les informations accessibles pour chaque partie de la légende. Lorsqu'une application de type accessible utilise ce contrôle, le contrôle peut fournir les informations accessibles nécessaires.
Cet exemple illustre l'utilisation de l'énumération AccessibleSelection avec la méthode Select. Consultez la vue d'ensemble de la classe AccessibleObject pour obtenir un exemple de code complet.
// 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 Professionnel Édition x64, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
Le .NET Framework et le .NET Compact Framework ne prennent pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.