UiObject
ui_object.UiObject
Scriptable handle for one node in the Android accessibility tree (same concepts as AccessibilityNodeInfo). Most action methods return a boolean indicating whether the framework accepted the gesture.
Table of contents
Constructors
Properties
Accessors
- accessibilityFocused
- availableExtraData
- boundsInScreen
- canOpenPopup
- checkable
- checked
- childCount
- children
- className
- clickable
- contentInvalid
- contextClickable
- desc
- dismissable
- drawingOrder
- editable
- enabled
- error
- focusable
- focused
- fullId
- hintText
- id
- inputType
- isHeading
- isImportantForAccessibility
- isMultiLine
- isPassword
- isTextEntryKey
- liveRegion
- longClickable
- maxTextLength
- originalText
- packageName
- paneTitle
- screenReaderFocusable
- scrollable
- selected
- showingHintText
- text
- textSelectionEnd
- textSelectionStart
- tooltipText
- visibleToUser
- windowId
Methods
- accessibilityFocus
- clearAccessibilityFocus
- clearFocus
- clearSelection
- click
- collapse
- contextClick
- copy
- cut
- dismiss
- expand
- focus
- longClick
- pageDown
- pageLeft
- pageRight
- pageUp
- paste
- recycle
- refresh
- scrollBackward
- scrollDown
- scrollForward
- scrollLeft
- scrollRight
- scrollToPosition
- scrollUp
- select
- setSelection
- setText
- showOnScreen
- tree
Constructors
constructor
• new UiObject(javaObject, depth, indexInParent, root?, parent?): UiObject
Construct a wrapper around an accessibility node.
Parameters
| Name | Type | Description |
|---|---|---|
javaObject | any | Underlying Android accessibility node (Java bridge object). |
depth | number | Depth from the virtual root. |
indexInParent | number | Zero-based index among the parent's children. |
root | undefined | UiObject | Virtual root UiObject for this subtree. |
parent | undefined | UiObject | Parent node, or undefined for the synthetic root. |
Returns
UiObject
Properties
depth
• Readonly depth: number
indexInParent
• Readonly indexInParent: number
javaObject
• Protected javaObject: any
parent
• Optional Readonly parent: UiObject
root
• Readonly root: UiObject
Accessors
accessibilityFocused
getaccessibilityFocused():boolean
Whether this node currently holds accessibility focus.
Returns
boolean
availableExtraData
getavailableExtraData():string[]
Extra metadata keys exposed by the platform.
Returns
string[]
boundsInScreen
getboundsInScreen():Rect
Bounding Rect in screen coordinates.
Returns
canOpenPopup
getcanOpenPopup():boolean
Whether the node can show a popup window.
Returns
boolean
checkable
getcheckable():boolean
Whether the node exposes a checkable state.
Returns
boolean
checked
getchecked():boolean
Whether the node is currently checked.
Returns
boolean
childCount
getchildCount():number
Child count.
Returns
number
children
getchildren:UiObject[]
Child UiObject list.
Returns
UiObject[]
className
getclassName():string
View class name (for example android.widget.TextView).
Returns
string
clickable
getclickable():boolean
Whether the node is clickable.
Returns
boolean
contentInvalid
getcontentInvalid():boolean
Whether the node reports invalid content (for example failed validation).
Returns
boolean
contextClickable
getcontextClickable():boolean
Whether the node supports a context click / right-click action.
Returns
boolean
desc
getdesc():string
Content description / accessibility label.
Returns
string
dismissable
getdismissable():boolean
Whether the node can be dismissed (for example a snack bar).
Returns
boolean
drawingOrder
getdrawingOrder():number
Z-order within the parent; useful to disambiguate overlapping siblings.
Returns
number
editable
geteditable():boolean
Whether the node is editable text.
Returns
boolean
enabled
getenabled():boolean
Enabled state; disabled nodes are usually greyed out and non-interactive.
Returns
boolean
error
geterror():string
Error text shown for invalid inputs.
Returns
string
focusable
getfocusable():boolean
Whether the node can take focus.
Returns
boolean
focused
getfocused():boolean
Whether the node currently has input focus.
Returns
boolean
fullId
getfullId():string
Fully qualified resource id, including activity / package prefix when applicable.
Returns
string
hintText
gethintText():string
Hint text for text fields.
Returns
string
id
getid():string
Short resource id without the package prefix.
Returns
string
inputType
getinputType():number
Android InputType bitmask.
See also
Returns
number
isHeading
getisHeading():boolean
Whether the node is marked as a heading for accessibility.
Returns
boolean
isImportantForAccessibility
getisImportantForAccessibility():boolean
Whether the node is marked important for accessibility.
Returns
boolean
isMultiLine
getisMultiLine():boolean
Whether the editor spans multiple lines.
Returns
boolean
isPassword
getisPassword():boolean
Whether this field masks characters as a password.
Returns
boolean
isTextEntryKey
getisTextEntryKey():boolean
Whether the node acts as a text-entry key on a keyboard.
Returns
boolean
liveRegion
getliveRegion():number
LiveRegion mode.
- Live regions announce important dynamic changes to assistive services.
- Example: a login
TextViewthat shows an error may useACCESSIBILITY_LIVE_REGION_POLITE.
Returns
number
longClickable
getlongClickable():boolean
Whether the node supports long-click.
Returns
boolean
maxTextLength
getmaxTextLength():number
Maximum allowed text length, if reported.
Returns
number
originalText
getoriginalText():string
Original (untransformed) text buffer when exposed.
Returns
string
packageName
getpackageName():string
Owning application package name.
Returns
string
paneTitle
getpaneTitle():string
Title of the hosting pane / window region.
Returns
boolean
screenReaderFocusable
getscreenReaderFocusable():boolean
Whether screen readers should treat the node as independently focusable.
Returns
boolean
scrollable
getscrollable():boolean
Whether the node can scroll.
Returns
boolean
selected
getselected():boolean
Selection state (for example a toggle toolbar button stays true while its panel is open).
Returns
boolean
showingHintText
getshowingHintText():boolean
Whether hint text is currently visible.
Returns
boolean
text
gettext():string
Rendered text content.
Returns
string
textSelectionEnd
gettextSelectionEnd():number
Exclusive end index of the current selection.
Returns
number
textSelectionStart
gettextSelectionStart():number
Inclusive start index of the current selection.
Returns
number
tooltipText
gettooltipText():string
Tooltip / hover text.
Returns
string
visibleToUser
getvisibleToUser():boolean
Whether the node is visible to the user.
Returns
boolean
windowId
getwindowId():number
Hosting window id from the accessibility hierarchy.
Returns
number
Methods
accessibilityFocus
- accessibilityFocus(): boolean
Request accessibility focus on this node.
Returns
boolean — true if the action succeeded.
clearAccessibilityFocus
- clearAccessibilityFocus(): boolean
Clear accessibility focus.
Returns
boolean — true if the action succeeded.
clearFocus
- clearFocus(): boolean
Clear input focus.
Returns
boolean — true if the action succeeded.
clearSelection
- clearSelection(): boolean
Clear selection on this node.
Returns
boolean — true if the action succeeded.
click
- click(): boolean
Perform a click action on this node.
Returns false when clickable is false, the window is blocked, or the action is ignored—try tapping the center via coordinates if needed.
Returns
boolean — true if the click succeeded.
collapse
- collapse(): boolean
Collapse an expandable node.
Returns
boolean — true if the action succeeded.
contextClick
- contextClick(): boolean
Perform a context click (for example right-click).
Returns
boolean — true if the click succeeded.
copy
- copy(): boolean
Copy the current selection to the clipboard.
Returns
boolean — true if copy succeeded.
cut
- cut(): boolean
Cut the current selection to the clipboard.
Returns
boolean — true if cut succeeded.
dismiss
- dismiss(): boolean
Dismiss the node (dialogs, banners, …).
Returns
boolean — true if dismiss succeeded.
expand
- expand(): boolean
Expand an expandable node.
Returns
boolean — true if expand succeeded.
focus
- focus(): boolean
Move input focus to this node.
Returns
boolean — true if the action succeeded.
longClick
- longClick(): boolean
Perform a long-click action.
Returns
boolean — true if long-click succeeded.
pageDown
- pageDown(): boolean
Scroll one page down.
Returns
boolean — true if paging succeeded.
pageLeft
- pageLeft(): boolean
Scroll one page left.
Returns
boolean — true if paging succeeded.
pageRight
- pageRight(): boolean
Scroll one page right.
Returns
boolean — true if paging succeeded.
pageUp
- pageUp(): boolean
Scroll one page up.
Returns
boolean — true if paging succeeded.
paste
- paste(): boolean
Paste clipboard contents into this node.
Returns
boolean — true if paste succeeded.
recycle
- recycle(): void
Release cached JNI references for this wrapper.
Returns
void
refresh
- refresh(): void
Refresh cached properties from the live node.
Returns
void
scrollBackward
- scrollBackward(): boolean
Scroll backward (usually up or left).
Returns
boolean — true if scroll succeeded.
scrollDown
- scrollDown(): boolean
Scroll down.
Returns
boolean — true if scroll succeeded.
scrollForward
- scrollForward(): boolean
Scroll forward (usually down or right).
Returns
boolean — true if scroll succeeded.
scrollLeft
- scrollLeft(): boolean
Scroll left.
Returns
boolean — true if scroll succeeded.
scrollRight
- scrollRight(): boolean
Scroll right.
Returns
boolean — true if scroll succeeded.
scrollToPosition
- scrollToPosition(position: number): boolean
Scroll a collection to position.
Parameters
| Name | Type | Description |
|---|---|---|
position | number | Target adapter index / position. |
Returns
boolean — true if scroll succeeded.
scrollUp
- scrollUp(): boolean
Scroll up.
Returns
boolean — true if scroll succeeded.
select
- select(): boolean
Select this node.
Returns
boolean — true if selection succeeded.
setSelection
- setSelection(start: number, end: number): boolean
Set the text selection range.
Parameters
| Name | Type | Description |
|---|---|---|
start | number | Selection start (inclusive). |
end | number | Selection end (exclusive). |
Returns
boolean — true if selection succeeded.
setText
- setText(text: string): boolean
Replace / commit text (implementation depends on the control).
Parameters
| Name | Type | Description |
|---|---|---|
text | string | Text to apply. |
Returns
boolean — true if the action succeeded.
showOnScreen
- showOnScreen(): boolean
Bring this node into the visible viewport.
Returns
boolean — true if the action succeeded.
tree
- tree():
UiObject[]
Returns
UiObject[]
