Class Accessible

java.lang.Object
org.eclipse.swt.accessibility.Accessible

public class Accessible extends Object
Instances of this class provide a bridge between application code and assistive technology clients. Many platforms provide default accessible behavior for most widgets, and this class allows that default behavior to be overridden. Applications can get the default Accessible object for a control by sending it getAccessible, and then add an accessible listener to override simple items like the name and help string, or they can add an accessible control listener to override complex items. As a rule of thumb, an application would only want to use the accessible control listener to implement accessibility for a custom control.
Since:
2.0
See Also:
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Deprecated. 
     
    Constructs a new instance of this class given its parent.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds the listener to the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleActionListener interface.
    void
    Adds the listener to the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleAttributeListener interface.
    void
    Adds the listener to the collection of listeners who will be notified when an accessible client asks for custom control specific information.
    void
    Adds the listener to the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleEditableTextListener interface.
    void
    Adds the listener to the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleHyperlinkListener interface.
    void
    Adds the listener to the collection of listeners who will be notified when an accessible client asks for certain strings, such as name, description, help, or keyboard shortcut.
    void
    Adds the listener to the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleTableCellListener interface.
    void
    Adds the listener to the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleTableListener interface.
    void
    Adds the listener to the collection of listeners who will be notified when an accessible client asks for custom text control specific information.
    void
    Adds the listener to the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleValueListener interface.
    void
    addRelation(int type, Accessible target)
    Adds a relation with the specified type and target to the receiver's set of relations.
    void
    Disposes of the operating system resources associated with the receiver, and removes the receiver from its parent's list of children.
    Returns the control for this Accessible object.
    void
    Invokes platform specific functionality to dispose an accessible object.
    static Accessible
    Invokes platform specific functionality to allocate a new accessible object.
    long
    internal_WM_GETOBJECT(long wParam, long lParam)
    Invokes platform specific functionality to handle a window message.
    void
    Removes the listener from the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleActionListener interface.
    void
    Removes the listener from the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleAttributeListener interface.
    void
    Removes the listener from the collection of listeners who will be notified when an accessible client asks for custom control specific information.
    void
    Removes the listener from the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleEditableTextListener interface.
    void
    Removes the listener from the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleHyperlinkListener interface.
    void
    Removes the listener from the collection of listeners who will be notified when an accessible client asks for certain strings, such as name, description, help, or keyboard shortcut.
    void
    Removes the listener from the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleTableCellListener interface.
    void
    Removes the listener from the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleTableListener interface.
    void
    Removes the listener from the collection of listeners who will be notified when an accessible client asks for custom text control specific information.
    void
    Removes the listener from the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleValueListener interface.
    void
    removeRelation(int type, Accessible target)
    Removes the relation with the specified type and target from the receiver's set of relations.
    void
    Sends a message to accessible clients that the child selection within a custom container control has changed.
    void
    sendEvent(int event, Object eventData)
    Sends a message with event-specific data to accessible clients indicating that something has changed within a custom control.
    void
    sendEvent(int event, Object eventData, int childID)
    Sends a message with event-specific data and a childID to accessible clients, indicating that something has changed within a custom control.
    void
    setFocus(int childID)
    Sends a message to accessible clients indicating that the focus has changed within a custom control.
    void
    textCaretMoved(int index)
    Sends a message to accessible clients that the text caret has moved within a custom control.
    void
    textChanged(int type, int startIndex, int length)
    Sends a message to accessible clients that the text within a custom control has changed.
    void
    Sends a message to accessible clients that the text selection has changed within a custom control.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

  • Method Details

    • internal_new_Accessible

      public static Accessible internal_new_Accessible(Control control)
      Invokes platform specific functionality to allocate a new accessible object.

      IMPORTANT: This method is not part of the public API for Accessible. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms, and should never be called from application code.

      Parameters:
      control - the control to get the accessible object for
      Returns:
      the platform specific accessible object
      Restriction:
      This method is not intended to be referenced by clients.
    • addAccessibleListener

      public void addAccessibleListener(AccessibleListener listener)
      Adds the listener to the collection of listeners who will be notified when an accessible client asks for certain strings, such as name, description, help, or keyboard shortcut. The listener is notified by sending it one of the messages defined in the AccessibleListener interface.
      Parameters:
      listener - the listener that should be notified when the receiver is asked for a name, description, help, or keyboard shortcut string
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      See Also:
    • addAccessibleControlListener

      public void addAccessibleControlListener(AccessibleControlListener listener)
      Adds the listener to the collection of listeners who will be notified when an accessible client asks for custom control specific information. The listener is notified by sending it one of the messages defined in the AccessibleControlListener interface.
      Parameters:
      listener - the listener that should be notified when the receiver is asked for custom control specific information
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      See Also:
    • addAccessibleTextListener

      public void addAccessibleTextListener(AccessibleTextListener listener)
      Adds the listener to the collection of listeners who will be notified when an accessible client asks for custom text control specific information. The listener is notified by sending it one of the messages defined in the AccessibleTextListener and AccessibleTextExtendedListener interfaces.
      Parameters:
      listener - the listener that should be notified when the receiver is asked for custom text control specific information
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      Since:
      3.0
      See Also:
    • addAccessibleActionListener

      public void addAccessibleActionListener(AccessibleActionListener listener)
      Adds the listener to the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleActionListener interface.
      Parameters:
      listener - the listener that should be notified when the receiver is asked for AccessibleActionListener interface properties
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      Since:
      3.6
      See Also:
    • addAccessibleEditableTextListener

      public void addAccessibleEditableTextListener(AccessibleEditableTextListener listener)
      Adds the listener to the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleEditableTextListener interface.
      Parameters:
      listener - the listener that should be notified when the receiver is asked for AccessibleEditableTextListener interface properties
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      Since:
      3.7
      See Also:
    • addAccessibleHyperlinkListener

      public void addAccessibleHyperlinkListener(AccessibleHyperlinkListener listener)
      Adds the listener to the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleHyperlinkListener interface.
      Parameters:
      listener - the listener that should be notified when the receiver is asked for AccessibleHyperlinkListener interface properties
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      Since:
      3.6
      See Also:
    • addAccessibleTableListener

      public void addAccessibleTableListener(AccessibleTableListener listener)
      Adds the listener to the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleTableListener interface.
      Parameters:
      listener - the listener that should be notified when the receiver is asked for AccessibleTableListener interface properties
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      Since:
      3.6
      See Also:
    • addAccessibleTableCellListener

      public void addAccessibleTableCellListener(AccessibleTableCellListener listener)
      Adds the listener to the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleTableCellListener interface.
      Parameters:
      listener - the listener that should be notified when the receiver is asked for AccessibleTableCellListener interface properties
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      Since:
      3.6
      See Also:
    • addAccessibleValueListener

      public void addAccessibleValueListener(AccessibleValueListener listener)
      Adds the listener to the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleValueListener interface.
      Parameters:
      listener - the listener that should be notified when the receiver is asked for AccessibleValueListener interface properties
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      Since:
      3.6
      See Also:
    • addAccessibleAttributeListener

      public void addAccessibleAttributeListener(AccessibleAttributeListener listener)
      Adds the listener to the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleAttributeListener interface.
      Parameters:
      listener - the listener that should be notified when the receiver is asked for AccessibleAttributeListener interface properties
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      Since:
      3.6
      See Also:
    • addRelation

      public void addRelation(int type, Accessible target)
      Adds a relation with the specified type and target to the receiver's set of relations.
      Parameters:
      type - an ACC constant beginning with RELATION_* indicating the type of relation
      target - the accessible that is the target for this relation
      Throws:
      IllegalArgumentException - ERROR_NULL_ARGUMENT - if the Accessible target is null
      Since:
      3.6
    • dispose

      public void dispose()
      Disposes of the operating system resources associated with the receiver, and removes the receiver from its parent's list of children.

      This method should be called when an accessible that was created with the public constructor Accessible(Accessible parent) is no longer needed. You do not need to call this when the receiver's control is disposed, because all Accessible instances associated with a control are released when the control is disposed. It is also not necessary to call this for instances of Accessible that were retrieved with Control.getAccessible().

      Since:
      3.6
    • getControl

      public Control getControl()
      Returns the control for this Accessible object.
      Returns:
      the receiver's control
      Since:
      3.0
    • internal_dispose_Accessible

      public void internal_dispose_Accessible()
      Invokes platform specific functionality to dispose an accessible object.

      IMPORTANT: This method is not part of the public API for Accessible. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms, and should never be called from application code.

      Restriction:
      This method is not intended to be referenced by clients.
    • internal_WM_GETOBJECT

      public long internal_WM_GETOBJECT(long wParam, long lParam)
      Invokes platform specific functionality to handle a window message.

      IMPORTANT: This method is not part of the public API for Accessible. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms, and should never be called from application code.

      Restriction:
      This method is not intended to be referenced by clients.
    • removeAccessibleListener

      public void removeAccessibleListener(AccessibleListener listener)
      Removes the listener from the collection of listeners who will be notified when an accessible client asks for certain strings, such as name, description, help, or keyboard shortcut.
      Parameters:
      listener - the listener that should no longer be notified when the receiver is asked for a name, description, help, or keyboard shortcut string
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      See Also:
    • removeAccessibleControlListener

      public void removeAccessibleControlListener(AccessibleControlListener listener)
      Removes the listener from the collection of listeners who will be notified when an accessible client asks for custom control specific information.
      Parameters:
      listener - the listener that should no longer be notified when the receiver is asked for custom control specific information
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      See Also:
    • removeAccessibleTextListener

      public void removeAccessibleTextListener(AccessibleTextListener listener)
      Removes the listener from the collection of listeners who will be notified when an accessible client asks for custom text control specific information.
      Parameters:
      listener - the listener that should no longer be notified when the receiver is asked for custom text control specific information
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      Since:
      3.0
      See Also:
    • removeAccessibleActionListener

      public void removeAccessibleActionListener(AccessibleActionListener listener)
      Removes the listener from the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleActionListener interface.
      Parameters:
      listener - the listener that should no longer be notified when the receiver is asked for AccessibleActionListener interface properties
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      Since:
      3.6
      See Also:
    • removeAccessibleEditableTextListener

      public void removeAccessibleEditableTextListener(AccessibleEditableTextListener listener)
      Removes the listener from the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleEditableTextListener interface.
      Parameters:
      listener - the listener that should no longer be notified when the receiver is asked for AccessibleEditableTextListener interface properties
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      Since:
      3.7
      See Also:
    • removeAccessibleHyperlinkListener

      public void removeAccessibleHyperlinkListener(AccessibleHyperlinkListener listener)
      Removes the listener from the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleHyperlinkListener interface.
      Parameters:
      listener - the listener that should no longer be notified when the receiver is asked for AccessibleHyperlinkListener interface properties
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      Since:
      3.6
      See Also:
    • removeAccessibleTableListener

      public void removeAccessibleTableListener(AccessibleTableListener listener)
      Removes the listener from the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleTableListener interface.
      Parameters:
      listener - the listener that should no longer be notified when the receiver is asked for AccessibleTableListener interface properties
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      Since:
      3.6
      See Also:
    • removeAccessibleTableCellListener

      public void removeAccessibleTableCellListener(AccessibleTableCellListener listener)
      Removes the listener from the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleTableCellListener interface.
      Parameters:
      listener - the listener that should no longer be notified when the receiver is asked for AccessibleTableCellListener interface properties
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      Since:
      3.6
      See Also:
    • removeAccessibleValueListener

      public void removeAccessibleValueListener(AccessibleValueListener listener)
      Removes the listener from the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleValueListener interface.
      Parameters:
      listener - the listener that should no longer be notified when the receiver is asked for AccessibleValueListener interface properties
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      Since:
      3.6
      See Also:
    • removeAccessibleAttributeListener

      public void removeAccessibleAttributeListener(AccessibleAttributeListener listener)
      Removes the listener from the collection of listeners that will be notified when an accessible client asks for any of the properties defined in the AccessibleAttributeListener interface.
      Parameters:
      listener - the listener that should no longer be notified when the receiver is asked for AccessibleAttributeListener interface properties
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      Since:
      3.6
      See Also:
    • removeRelation

      public void removeRelation(int type, Accessible target)
      Removes the relation with the specified type and target from the receiver's set of relations.
      Parameters:
      type - an ACC constant beginning with RELATION_* indicating the type of relation
      target - the accessible that is the target for this relation
      Throws:
      IllegalArgumentException - ERROR_NULL_ARGUMENT - if the Accessible target is null
      Since:
      3.6
    • sendEvent

      public void sendEvent(int event, Object eventData)
      Sends a message with event-specific data to accessible clients indicating that something has changed within a custom control.
      Parameters:
      event - an ACC constant beginning with EVENT_* indicating the message to send
      eventData - an object containing event-specific data, or null if there is no event-specific data (eventData is specified in the documentation for individual ACC.EVENT_* constants)
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      Since:
      3.6
      See Also:
    • sendEvent

      public void sendEvent(int event, Object eventData, int childID)
      Sends a message with event-specific data and a childID to accessible clients, indicating that something has changed within a custom control. NOTE: This API is intended for applications that are still using childIDs. Moving forward, applications should use accessible objects instead of childIDs.
      Parameters:
      event - an ACC constant beginning with EVENT_* indicating the message to send
      eventData - an object containing event-specific data, or null if there is no event-specific data (eventData is specified in the documentation for individual ACC.EVENT_* constants)
      childID - an identifier specifying a child of the control
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      Since:
      3.8
      See Also:
    • selectionChanged

      public void selectionChanged()
      Sends a message to accessible clients that the child selection within a custom container control has changed.
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      Since:
      3.0
    • setFocus

      public void setFocus(int childID)
      Sends a message to accessible clients indicating that the focus has changed within a custom control.
      Parameters:
      childID - an identifier specifying a child of the control
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
    • textCaretMoved

      public void textCaretMoved(int index)
      Sends a message to accessible clients that the text caret has moved within a custom control.
      Parameters:
      index - the new caret index within the control
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      Since:
      3.0
    • textChanged

      public void textChanged(int type, int startIndex, int length)
      Sends a message to accessible clients that the text within a custom control has changed.
      Parameters:
      type - the type of change, one of ACC.TEXT_INSERT or ACC.TEXT_DELETE
      startIndex - the text index within the control where the insertion or deletion begins
      length - the non-negative length in characters of the insertion or deletion
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      Since:
      3.0
      See Also:
    • textSelectionChanged

      public void textSelectionChanged()
      Sends a message to accessible clients that the text selection has changed within a custom control.
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control
      Since:
      3.0
    • toString

      public String toString()
      Overrides:
      toString in class Object