harmony 鸿蒙@ohos.application.AccessibilityExtensionAbility (AccessibilityExtensionAbility)

  • 2022-10-28
  • 浏览 (744)

@ohos.application.AccessibilityExtensionAbility (AccessibilityExtensionAbility)

The AccessibilityExtensionAbility module provides accessibility extension capabilities based on the ExtensionAbility framework.

NOTE

The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.

Modules to Import

import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility';

Attributes

System capability: SystemCapability.BarrierFree.Accessibility.Core

Name Type Readable Writable Description
context AccessibilityExtensionContext Yes No Context of the accessibility extension ability.

AccessibilityEvent

Defines an accessibility event.

System capability: SystemCapability.BarrierFree.Accessibility.Core

Attributes

Name Type Readable Writable Description
eventType accessibility.EventType |accessibility.WindowUpdateType|TouchGuideType |GestureType |PageUpdateType Yes No Event type.
EventType: accessibility event type.
WindowUpdateType: Window update type.
TouchGuideType: touch guide event type.
GestureType: gesture type.
PageUpdateType: page update type, which is not supported currently.
target AccessibilityElement Yes No Target component where the event occurs.
timeStamp number Yes No Timestamp of the event.

GestureType

Enumerates gesture types.

System capability: SystemCapability.BarrierFree.Accessibility.Core

Name Description
left Left gesture. String type.
leftThenRight Left-then-right gesture. String type.
leftThenUp Left-then-up gesture. String type.
leftThenDown Left-then-down gesture. String type.
right Right gesture. String type.
rightThenLeft Right-then-left gesture. String type.
rightThenUp Right-then-up gesture. String type.
rightThenDown Right-then-down gesture. String type.
up Up gesture. String type.
upThenLeft Up-then-left gesture. String type.
upThenRight Up-then-right gesture. String type.
upThenDown Up-then-down gesture. String type.
down Down gesture. String type.
downThenLeft Down-then-left gesture. String type.
downThenRight Down-then-right gesture. String type.
downThenUp Down-then-up gesture. String type.

PageUpdateType

Enumerates the page update types. This API is not supported currently.

System capability: SystemCapability.BarrierFree.Accessibility.Core

Name Description
pageContentUpdate Update of the page content. String type.
pageStateUpdate Update of the page status. String type.

TouchGuideType

Enumerates the touch guide event types.

System capability: SystemCapability.BarrierFree.Accessibility.Core

Name Description
touchBegin Start of touch in touch guide mode. String type.
touchEnd End of touch in touch guide mode. String type.

AccessibilityExtensionAbility.onConnect

onConnect(): void;

Called when the AccessibilityExtensionAbility is enabled and connected to the system service. In this API, you can have the service logic initialized. This API can be overridden as required.

System capability: SystemCapability.BarrierFree.Accessibility.Core

Example

import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility';

class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
    onConnect(): void {
        console.log('AxExtensionAbility onConnect');
    }
}

AccessibilityExtensionAbility.onDisconnect

onDisconnect(): void;

Called when the AccessibilityExtensionAbility is disabled and disconnected from the system service. In this API, you can implement the service logic of resource release and exit. This API can be overridden as required.

System capability: SystemCapability.BarrierFree.Accessibility.Core

Example

import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility';

class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
    onDisconnect(): void {
        console.log('AxExtensionAbility onDisconnect');
    }
}

AccessibilityExtensionAbility.onAccessibilityEvent

onAccessibilityEvent(event: AccessibilityEvent): void;

Called when an event that matches the specified bundle and event type occurs. In this API, you can implement event-specific service logic. Generally, this API needs to be overridden.

System capability: SystemCapability.BarrierFree.Accessibility.Core

Parameters

Name Type Mandatory Description
event AccessibilityEvent Yes Accessibility event. No value is returned.

Example

import AccessibilityExtensionAbility , { AccessibilityEvent } from '@ohos.application.AccessibilityExtensionAbility';

class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
    onAccessibilityEvent(event: AccessibilityEvent): void {
        console.log('AxExtensionAbility onAccessibilityEvent');
        if (event.eventType === 'click') {
            console.log('AxExtensionAbility onAccessibilityEvent: click');
        }
    }
}

AccessibilityExtensionAbility.onKeyEvent

onKeyEvent(keyEvent: KeyEvent): boolean;

Called when a physical key is pressed. In this API, you can determine whether to intercept an event based on the service.

System capability: SystemCapability.BarrierFree.Accessibility.Core

Parameters

Name Type Mandatory Description
keyEvent KeyEvent Yes Key event. If true is returned, the key is intercepted.

Example

import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility';
import { KeyEvent } from '@ohos.multimodalInput.keyEvent';

class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
    onKeyEvent(keyEvent: KeyEvent): boolean {
        console.log('AxExtensionAbility onKeyEvent');
        if (keyEvent.key.code === 16) {
            console.log('AxExtensionAbility onKeyEvent: intercept 16');
            return true;
        }
        return false;
    }
}

你可能感兴趣的鸿蒙文章

harmony 鸿蒙APIs

harmony 鸿蒙System Common Events (To Be Deprecated Soon)

harmony 鸿蒙System Common Events

harmony 鸿蒙API Reference Document Description

harmony 鸿蒙Enterprise Device Management Overview (for System Applications Only)

harmony 鸿蒙BundleStatusCallback

harmony 鸿蒙@ohos.bundle.innerBundleManager (innerBundleManager)

harmony 鸿蒙@ohos.distributedBundle (Distributed Bundle Management)

harmony 鸿蒙@ohos.bundle (Bundle)

harmony 鸿蒙@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)

0  赞