Class AccessibleFieldPanelDelegate
The model for accessibility for the FieldPanel is a bit complex because the field panel displays text, but in a 2 dimensional array of fields, where each field has potentially 2 dimensional text. So for the purpose of accessibility, the FieldPanel acts as both a text field and a text component.
To support screen readers reacting to cursor movements in the FieldPanel, the FieldPanel acts like a text field, but it acts like it only has the text of one inner Field at a time (The one where the cursor is). The other approach that was considered was to treat the field panel as a single text document. This would be difficult to implement because of the way fields are multi-lined. Also, the user of the screen reader would lose all concepts that there are fields. By maintaining the fields as a concept to the screen reader, it can provide more meaningful descriptions as the cursor is moved between fields.
The Field panel also acts as an AccessibleComponent
with virtual children for each of its
visible fields. This is what allows screen readers to read the context of whatever the mouse
is hovering over keeping the data separated by the field boundaries.
-
Constructor Summary
ConstructorDescriptionAccessibleFieldPanelDelegate
(List<AnchoredLayout> layouts, AccessibleContext context, FieldPanel panel) -
Method Summary
Modifier and TypeMethodDescriptionReturns theAccessibleField
that is at the given point relative to the FieldPanel.getAccessibleField
(int fieldNum) Returns the n'th AccessibleField that is visible on the screen.Returns the AccessibleField associated with the given field location.getAfterIndex
(int part, int index) Returns the char, word, or sentence after the given char index.getAtIndex
(int part, int index) Returns the char, word, or sentence at the given char index.getBeforeIndex
(int part, int index) Returns the char, word, or sentence at the given char index.int
Returns the caret position relative the current active field.getCharacterBounds
(int index) Return the bounds relative to the field panel for the character at the given indexint
Returns the number of characters in the current active field.int
Returns the number of visible field showing on the screen in the field panel.Returns a description of the current fieldint
Returns the character index at the given point relative to the FieldPanel.Returns either null if the field is not selected or the full field text if it is selected.int
Returns the selection character end index.int
Returns the selection character start index.void
setCaret
(FieldLocation newCursorLoc, EventTrigger trigger) Tells this delegate that the cursor moved.void
Sets theFieldDescriptionProvider
that can generate descriptions of the current field.void
setLayouts
(List<AnchoredLayout> layouts) Whenever the set of visible layouts changes, the field panel rebuilds its info for the new visible fields and notifies the accessibility system that its children changed.void
setSelection
(FieldSelection currentSelection, EventTrigger trigger) Tells this delegate that the selection has changed.
-
Constructor Details
-
AccessibleFieldPanelDelegate
public AccessibleFieldPanelDelegate(List<AnchoredLayout> layouts, AccessibleContext context, FieldPanel panel)
-
-
Method Details
-
setLayouts
Whenever the set of visible layouts changes, the field panel rebuilds its info for the new visible fields and notifies the accessibility system that its children changed.- Parameters:
layouts
- the new set of visible layouts.
-
setCaret
Tells this delegate that the cursor moved. It updates its internal state and fires events to the accessibility system.- Parameters:
newCursorLoc
- the new FieldLoation of the cursortrigger
- the event trigger
-
setSelection
Tells this delegate that the selection has changed. If the current field is in the selection, it sets the current AccessibleField to be selected. (A field is either entirely selected or not)- Parameters:
currentSelection
- the new current field panel selectiontrigger
- the event trigger
-
getCaretPosition
public int getCaretPosition()Returns the caret position relative the current active field.- Returns:
- the caret position relative the current active field
-
getCharCount
public int getCharCount()Returns the number of characters in the current active field.- Returns:
- the number of characters in the current active field.
-
getAccessibleField
Returns the n'th AccessibleField that is visible on the screen.- Parameters:
fieldNum
- the number of the field to get- Returns:
- the n'th AccessibleField that is visible on the screen
-
getAccessibleField
Returns the AccessibleField associated with the given field location.- Parameters:
loc
- the FieldLocation to get the visible field for- Returns:
- the AccessibleField associated with the given field location
-
getCharacterBounds
Return the bounds relative to the field panel for the character at the given index- Parameters:
index
- the index of the character in the active field whose bounds is to be returned.- Returns:
- the bounds relative to the field panel for the character at the given index
-
getIndexAtPoint
Returns the character index at the given point relative to the FieldPanel. Note this only returns chars in the active field.- Parameters:
p
- the point to get the character for- Returns:
- the character index at the given point relative to the FieldPanel.
-
getAtIndex
Returns the char, word, or sentence at the given char index.- Parameters:
part
- specifies char, word or sentence (SeeAccessibleText
)index
- the character index to get data for- Returns:
- the char, word, or sentences at the given char index
-
getAfterIndex
Returns the char, word, or sentence after the given char index.- Parameters:
part
- specifies char, word or sentence (SeeAccessibleText
)index
- the character index to get data for- Returns:
- the char, word, or sentence after the given char index
-
getBeforeIndex
Returns the char, word, or sentence at the given char index.- Parameters:
part
- specifies char, word or sentence (SeeAccessibleText
)index
- the character index to get data for- Returns:
- the char, word, or sentence at the given char index
-
getFieldCount
public int getFieldCount()Returns the number of visible field showing on the screen in the field panel.- Returns:
- the number of visible field showing on the screen in the field panel
-
getAccessibleAt
Returns theAccessibleField
that is at the given point relative to the FieldPanel.- Parameters:
p
- the point to get an Accessble child at- Returns:
- the
AccessibleField
that is at the given point relative to the FieldPanel
-
getFieldDescription
Returns a description of the current field- Returns:
- a description of the current field
-
setFieldDescriptionProvider
Sets theFieldDescriptionProvider
that can generate descriptions of the current field.- Parameters:
provider
- the description provider
-
getSelectionStart
public int getSelectionStart()Returns the selection character start index. This currently always returns 0 as selections are all or nothing.- Returns:
- the selection character start index.
-
getSelectionEnd
public int getSelectionEnd()Returns the selection character end index. This is either 0, indicating there is no selection or the index at the end of the text meaning the entire field is selected.- Returns:
- the selection character start index.
-
getSelectedText
Returns either null if the field is not selected or the full field text if it is selected.- Returns:
- either null if the field is not selected or the full field text if it is selected
-