提交 f9f7b70c 编写于 作者: S shawn_he

update doc

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 db256e73
......@@ -36,12 +36,6 @@ Your application can use the location function only after the user has granted t
Since the location information is considered sensitive, your application still needs to obtain the location access permission from the user even if the user has turned on the location function. The system will provide the location service for your application only after it has been granted the permission to access the device location information.
### Samples
The following sample is provided to help you better understand how to develop location services:
- [`Location`: Location (ArkTS) (API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/device/Location)
## Applying for Location Permissions
......@@ -103,7 +97,7 @@ The following table lists the APIs used to obtain the device location informatio
### How to Develop
1. Before using basic location capabilities, check whether your application has been granted the permission to access device location information. If not, your application first needs to apply for the required permission. For details, see [Applying for Location Permissions](#applying-for-location-permissions).
1. Before using system basic location capabilities, check whether your application has been granted the permission to access the device location information. If not, your application first needs to apply for the required permission. For details, see [Applying for Location Permissions](#applying-for-location-permissions).
2. Import the **geoLocationManager** module by which you can implement all APIs related to the basic location capabilities.
......@@ -149,7 +143,7 @@ The following table lists the APIs used to obtain the device location informatio
Sample code for initializing **requestInfo** for navigation:
```ts
let requestInfo = {'scenario': geoLocationManager.LocationRequestScenario.NAVIGATION, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0};
let requestInfo:geoLocationManager.LocationRequest = {'scenario': geoLocationManager.LocationRequestScenario.NAVIGATION, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0};
```
**Method 2:**
......@@ -179,14 +173,14 @@ The following table lists the APIs used to obtain the device location informatio
Sample code for initializing **requestInfo** for the location accuracy priority policy:
```ts
let requestInfo = {'priority': geoLocationManager.LocationRequestPriority.ACCURACY, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0};
let requestInfo:geoLocationManager.LocationRequest = {'priority': geoLocationManager.LocationRequestPriority.ACCURACY, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0};
```
4. Instantiate the **Callback** object for the system to report location results.
Your application needs to implement the callback defined by the system. When the system successfully obtains the real-time location of a device, it will report the location result to your application through the callback interface. Your application can implement the callback interface in such a way to complete your own service logic.
```ts
let locationChange = (location) => {
let locationChange = (location:geoLocationManager.Location):void => {
console.log('locationChanger: data: ' + JSON.stringify(location));
};
```
......@@ -209,10 +203,11 @@ The following table lists the APIs used to obtain the device location informatio
```ts
import geoLocationManager from '@ohos.geoLocationManager';
import BusinessError from "@ohos.base";
try {
let location = geoLocationManager.getLastLocation();
} catch (err) {
console.error("errCode:" + err.code + ",errMessage:" + err.message);
console.error("errCode:" + (err as BusinessError.BusinessError).code + ",errMessage:" + (err as BusinessError.BusinessError).message);
}
```
......@@ -259,10 +254,11 @@ The following table lists the APIs used for mutual conversion between coordinate
```ts
import geoLocationManager from '@ohos.geoLocationManager';
import BusinessError from "@ohos.base";
try {
let isAvailable = geoLocationManager.isGeocoderAvailable();
} catch (err) {
console.error("errCode:" + err.code + ",errMessage:" + err.message);
console.error("errCode:" + (err as BusinessError.BusinessError).code + ",errMessage:" + (err as BusinessError.BusinessError).message);
}
```
......@@ -270,7 +266,7 @@ The following table lists the APIs used for mutual conversion between coordinate
- Call **getAddressesFromLocation** to convert coordinates into geographical location information.
```ts
let reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1};
let reverseGeocodeRequest:geoLocationManager.ReverseGeoCodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1};
try {
geoLocationManager.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => {
if (err) {
......@@ -280,7 +276,7 @@ The following table lists the APIs used for mutual conversion between coordinate
}
});
} catch (err) {
console.error("errCode:" + err.code + ",errMessage:" + err.message);
console.error("errCode:" + (err as BusinessError.BusinessError).code + ",errMessage:" + (err as BusinessError.BusinessError).message);
}
```
......@@ -288,7 +284,7 @@ The following table lists the APIs used for mutual conversion between coordinate
- Call **getAddressesFromLocationName** to convert geographic descriptions into coordinates.
```ts
let geocodeRequest = {"description": "No. xx, xx Road, Pudong District, Shanghai", "maxItems": 1};
let geocodeRequest:geoLocationManager.GeoCodeRequest = {"description": "No. xx, xx Road, Pudong District, Shanghai", "maxItems": 1};
try {
geoLocationManager.getAddressesFromLocationName(geocodeRequest, (err, data) => {
if (err) {
......@@ -298,7 +294,7 @@ The following table lists the APIs used for mutual conversion between coordinate
}
});
} catch (err) {
console.error("errCode:" + err.code + ",errMessage:" + err.message);
console.error("errCode:" + (err as BusinessError.BusinessError).code + ",errMessage:" + (err as BusinessError.BusinessError).message);
}
```
......@@ -332,11 +328,12 @@ The following table lists the APIs used for geofencing. For details, see [Geoloc
1. Declare the **ohos.permission.APPROXIMATELY_LOCATION** permission. For details, see [Applying for Location Permissions](#applying-for-location-permissions).
2. Import the [geoLocationManager](../reference/apis/js-apis-geoLocationManager.md) and [wantAgent](../reference/apis/js-apis-app-ability-wantAgent.md) modules.
2. Import the [geoLocationManager](../reference/apis/js-apis-geoLocationManager.md), [wantAgent](../reference/apis/js-apis-app-ability-wantAgent.md), and [BusinessError](../reference/apis/js-apis-base.md) modules.
```ts
import geoLocationManager from '@ohos.geoLocationManager';
import wantAgent from '@ohos.app.ability.wantAgent';
import wantAgent, {WantAgent as _wantAgent} from '@ohos.app.ability.wantAgent';
import BusinessError from "@ohos.base";
```
3. Create a [WantAgentInfo](../reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md) object.
......@@ -344,10 +341,10 @@ The following table lists the APIs used for geofencing. For details, see [Geoloc
Scenario 1: Create a **WantAgentInfo** object for starting an ability.
```ts
let wantAgentObj = null; // Save the created WantAgent object for completing the trigger operations at a later time.
let wantAgentObj:_wantAgent|null = null; // Save the created WantAgent object for completing the trigger operations at a later time.
// Set the operation type through operationType of the WantAgentInfo object.
let wantAgentInfo = {
let wantAgentInfo:wantAgent.WantAgentInfo = {
wants: [
{
deviceId: '',
......@@ -368,10 +365,10 @@ The following table lists the APIs used for geofencing. For details, see [Geoloc
Scenario 2: Create a **WantAgentInfo** object for publishing [common events](../application-models/common-event-overview.md).
```ts
let wantAgentObj = null; // Save the created WantAgent object for completing the trigger operations at a later time.
let wantAgentObj:_wantAgent|null = null; // Save the created WantAgent object for completing the trigger operations at a later time.
// Set the operation type through operationType of the WantAgentInfo object.
let wantAgentInfo = {
let wantAgentInfo:wantAgent.WantAgentInfo = {
wants: [
{
action: "event_name", // Set the event name.
......@@ -397,13 +394,14 @@ After obtaining the **WantAgent** object, call the geofencing API to add a geofe
}
console.info('getWantAgent success');
wantAgentObj = data;
let requestInfo = {'priority': 0x201, 'scenario': 0x301, "geofence": {"latitude": 121, "longitude": 26, "radius": 100, "expiration": 10000}};
let requestInfo:geoLocationManager.GeofenceRequest = {'scenario': 0x301, "geofence": {"latitude": 121, "longitude": 26, "radius": 100, "expiration": 10000}};
try {
geoLocationManager.on('gnssFenceStatusChange', requestInfo, wantAgentObj);
} catch (err) {
console.error("errCode:" + err.code + ",errMessage:" + err.message);
console.error("errCode:" + (err as BusinessError.BusinessError).code + ",errMessage:" + (err as BusinessError.BusinessError).message);
}
});
```
5. Have the system automatically trigger the action defined for the **WantAgent** object when a device enters or exits the geofence.
......@@ -394,6 +394,27 @@ promise.then(data => {
});
```
## call.hasCallSync<sup>10+</sup>
hasCallSync\(\): boolean
Checks whether a call is in progress.
**System capability**: SystemCapability.Telephony.CallManager
**Return value**
| Type | Description |
| ---------------------- |-------------|
| boolean | Promise used to return the result.|
**Example**
```js
let hasCall = call.hasCallSync();
console.log(`hasCallSync success, has call is ' + hasCall);
```
## call.getCallState
......@@ -443,6 +464,27 @@ promise.then(data => {
});
```
## call.getCallStateSync<sup>10+</sup>
getCallStateSync\(\): CallState
Obtains the call status.
**System capability**: SystemCapability.Telephony.CallManager
**Return value**
| Type | Description |
| ------------------------------------- |-------------|
| [CallState](#callstate) | Promise used to return the result.|
**Example**
```js
let callState = call.getCallStateSync();
console.log(`the call state is:` + callState);
```
## call.hasVoiceCapability<sup>7+</sup>
hasVoiceCapability\(\): boolean
......@@ -2821,7 +2863,7 @@ call.off('mmiCodeResult', data => {
## call.on('audioDeviceChange')<sup>10+</sup>
on\(type: 'audioDeviceChange', callback: Callback\<AudioDeviceInfo\>\): void
on\(type: 'audioDeviceChange', callback: Callback\<AudioDeviceCallbackInfo\>\): void
Subscribes to audio device change events. This API uses an asynchronous callback to return the result.
......@@ -2836,7 +2878,7 @@ Subscribes to audio device change events. This API uses an asynchronous callback
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------- | ---- | --------------------------------------------------- |
| type | string | Yes | Audio device change. This field has a fixed value of **audioDeviceChange**.|
| callback | Callback<[AudioDeviceInfo](#audiodeviceinfo10)> | Yes | Callback used to return the result. |
| callback | Callback<[AudioDeviceCallbackInfo](#audiodevicecallbackinfo10)> | Yes | Callback used to return the result. |
**Error codes**
......@@ -2863,7 +2905,7 @@ call.on('audioDeviceChange', data => {
## call.off('audioDeviceChange')<sup>10+</sup>
off\(type: 'audioDeviceChange', callback?: Callback\<AudioDeviceInfo\>\): void
off\(type: 'audioDeviceChange', callback?: Callback\<AudioDeviceCallbackInfo\>\): void
Unsubscribes from **audioDeviceChange** events. This API uses an asynchronous callback to return the result.
......@@ -2878,7 +2920,7 @@ Unsubscribes from **audioDeviceChange** events. This API uses an asynchronous ca
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------------------------- | ---- | --------------------------------------------------- |
| type | string | Yes | Audio device change. This field has a fixed value of **audioDeviceChange**.|
| callback | Callback<[AudioDeviceInfo](#audiodeviceinfo10)> | No | Callback used to return the result. If this parameter is not set, no subscription cancellation result will be received. |
| callback | Callback<[AudioDeviceCallbackInfo](#audiodevicecallbackinfo10)> | No | Callback used to return the result. If this parameter is not set, no subscription cancellation result will be received. |
**Error codes**
......@@ -4978,7 +5020,7 @@ Enumerates audio device types.
| DEVICE_WIRED_HEADSET | 2 | Wired headset device.|
| DEVICE_BLUETOOTH_SCO | 3 | Bluetooth SCO device. |
## AudioDeviceInfo<sup>10+</sup>
## AudioDeviceCallbackInfo<sup>10+</sup>
Defines the audio device information.
......@@ -5192,9 +5234,11 @@ Enumerates call ability event IDs.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Value | Description |
| ------------------------ | ---- | --------------- |
| ------------------------------------- | ---- | --------------- |
| EVENT_DIAL_NO_CARRIER | 1 | No available carrier during dialing. |
| EVENT_INVALID_FDN_NUMBER | 2 | Invalid FDN.|
| EVENT_HOLD_CALL_FAILED<sup>11+</sup> | 3 | Failed to place the call on hold.|
| EVENT_SWAP_CALL_FAILED<sup>11+</sup> | 4 | Failed to place the current call on hold and answer the waiting call.|
## DialScene<sup>8+</sup>
......
# @ohos.multimodalInput.inputDeviceCooperate (Screen Hopping)
# @ohos.multimodalInput.inputDeviceCooperate (Screen Hopping) (To Be Deprecated Soon)
The **inputDeviceCooperate** module implements screen hopping for two or more networked devices to share the keyboard and mouse for collaborative operations.
......@@ -108,8 +108,8 @@ For details about the error codes, see [Screen Hopping Error Codes](../errorcode
| ID| Error Message|
| -------- | ---------------------------------------- |
| 4400001 | This error code is reported if an invalid device descriptor is passed to the screen hopping API. |
| 4400002 | This error code is reported if the screen hopping status is abnormal when the screen hopping API is called. |
| 4400001 | Incorrect descriptor for the target device. |
| 4400002 | Screen hop failed. |
**Example**
......@@ -158,8 +158,8 @@ For details about the error codes, see [Screen Hopping Error Codes](../errorcode
| ID| Error Message|
| -------- | ---------------------------------------- |
| 4400001 | This error code is reported if an invalid device descriptor is passed to the screen hopping API. |
| 4400002 | This error code is reported if the screen hopping status is abnormal when the screen hopping API is called. |
| 4400001 | Incorrect descriptor for the target device. |
| 4400002 | Screen hop failed. |
**Example**
......
# @ohos.deviceStatus.dragInteraction (Drag Interaction)
The **dragInteraction** module provides the APIs to enable and disable listening for dragging status changes.
> **NOTE**
>
> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs provided by this module are system APIs.
## Modules to Import
```js
import dragInteraction from '@ohos.deviceStatus.dragInteraction'
```
## dragInteraction.on('drag')
on(type: 'drag', callback: Callback&lt;DragState&gt;): void;
Enables listening for dragging status changes.
**System capability**: SystemCapability.Msdp.DeviceStatus.Drag
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ---------------------------- |
| type | string | Yes | Event type. This field has a fixed value of **drag**.|
| callback | Callback&lt;[DragState](#dragstate)&gt; | Yes | Callback used to return the dragging status.|
**Example**
```js
try {
dragInteraction.on('drag', (data) => {
console.log(`Drag interaction event: ${JSON.stringify(data)}`);
});
} catch (error) {
console.log(`Register failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## dragInteraction.off('drag')
off(type: 'drag', callback?: Callback&lt;DragState&gt;): void;
Disables listening for dragging status changes.
**System capability**: SystemCapability.Msdp.DeviceStatus.Drag
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------------- | ---- | ---------------------------- |
| type | string | Yes | Event type. This field has a fixed value of **drag**.|
| callback | Callback&lt;[DragState](#dragstate)> | No | Callback to be unregistered. If this parameter is not specified, all callbacks registered by the current application will be unregistered.|
**Example**
```js
// Unregister a single callback.
function callback(event) {
console.log(`Drag interaction event: ${JSON.stringify(event)}`);
return false;
}
try {
dragInteraction.on('drag', callback);
dragInteraction.off("drag", callback);
} catch (error) {
console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
```js
// Unregister all callbacks.
function callback(event) {
console.log(`Drag interaction event: ${JSON.stringify(event)}`);
return false;
}
try {
dragInteraction.on('drag', callback);
dragInteraction.off("drag");
} catch (error) {
console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## DragState
Enumerates dragging states.
**System capability**: SystemCapability.Msdp.DeviceStatus.Drag
| Name | Value | Description |
| -------- | ----------------- | ----------------- |
| MSG_DRAG_STATE_START | 1 | Dragging starts.|
| MSG_DRAG_STATE_STOP | 2 | Dragging is ended. |
| MSG_DRAG_STATE_CANCEL | 3 | Dragging is canceled. |
......@@ -122,7 +122,7 @@ Defines parameters for an **AppEventInfo** object.
| Name | Type | Mandatory| Description |
| --------- | ----------------------- | ---- | ------------------------------------------------------------ |
| domain | string | Yes | Event domain. The value is a string of up to 32 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (_).|
| domain | string | Yes | Event domain. The value is a string of up to 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (_).|
| name | string | Yes | Event name. The value is a string of up to 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter or dollar sign ($) and cannot end with an underscore (_).|
| eventType | [EventType](#eventtype) | Yes | Event type. |
| params | object | Yes | Event parameter object, which consists of a parameter name and a parameter value. The specifications are as follows:<br>- The parameter name is a string of up to 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter or dollar sign ($) and cannot end with an underscore (_).<br>- The parameter value can be a string, number, boolean, or array. If the parameter value is a string, its maximum length is 8*1024 characters. If this limit is exceeded, excess characters will be discarded. If the parameter value is a number, the value must be within the range of **Number.MIN_SAFE_INTEGER** to **Number.MAX_SAFE_INTEGER**. Otherwise, uncertain values may be generated. If the parameter value is an array, the elements in the array must be of the same type, which can only be string, number, or boolean. In addition, the number of elements must be less than 100. If this limit is exceeded, excess elements will be discarded.<br>- The maximum number of parameters is 32. If this limit is exceeded, excess parameters will be discarded.|
......
......@@ -98,7 +98,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
let displayLanguage: string = I18n.System.getDisplayLanguage("zh", "en-GB"); // displayLanguage = Chinese
} catch(error) {
let err: BusinessError = error as BusinessError;
console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
console.error(`call System.getDisplayLanguage failed, error code: ${err.code}, message: ${err.message}.`);
}
```
......@@ -132,7 +132,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
let systemLanguages: Array<string> = I18n.System.getSystemLanguages(); // [ "en-Latn-US", "zh-Hans" ]
} catch(error) {
let err: BusinessError = error as BusinessError;
console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
console.error(`call System.getSystemLanguages failed, error code: ${err.code}, message: ${err.message}.`);
}
```
......@@ -172,7 +172,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
let systemCountries: Array<string> = I18n.System.getSystemCountries('zh'); // systemCountries = [ "ZW", "YT", "YE", ..., "ER", "CN", "DE" ], 240 countries or regions in total
} catch(error) {
let err: BusinessError = error as BusinessError;
console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
console.error(`call System.getSystemCountries failed, error code: ${err.code}, message: ${err.message}.`);
}
```
......@@ -213,7 +213,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
let res: boolean = I18n.System.isSuggested('zh', 'CN'); // res = true
} catch(error) {
let err: BusinessError = error as BusinessError;
console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
console.error(`call System.isSuggested failed, error code: ${err.code}, message: ${err.message}.`);
}
```
......@@ -247,7 +247,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
let systemLanguage: string = I18n.System.getSystemLanguage(); // systemLanguage indicates the current system language.
} catch(error) {
let err: BusinessError = error as BusinessError;
console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
console.error(`call System.getSystemLanguage failed, error code: ${err.code}, message: ${err.message}.`);
}
```
......@@ -285,7 +285,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
I18n.System.setSystemLanguage('zh'); // Set the current system language to zh.
} catch(error) {
let err: BusinessError = error as BusinessError;
console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
console.error(`call System.setSystemLanguage failed, error code: ${err.code}, message: ${err.message}.`);
}
```
......@@ -319,7 +319,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
let systemRegion: string = I18n.System.getSystemRegion(); // Obtain the current system region.
} catch(error) {
let err: BusinessError = error as BusinessError;
console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
console.error(`call System.getSystemRegion failed, error code: ${err.code}, message: ${err.message}.`);
}
```
......@@ -357,7 +357,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
I18n.System.setSystemRegion('CN'); // Set the current system region to CN.
} catch(error) {
let err: BusinessError = error as BusinessError;
console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
console.error(`call System.setSystemRegion failed, error code: ${err.code}, message: ${err.message}.`);
}
```
......@@ -391,7 +391,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
let systemLocale: string = I18n.System.getSystemLocale(); // Obtain the current system locale.
} catch(error) {
let err: BusinessError = error as BusinessError;
console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
console.error(`call System.getSystemLocale failed, error code: ${err.code}, message: ${err.message}.`);
}
```
......@@ -429,7 +429,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
I18n.System.setSystemLocale('zh-CN'); // Set the current system locale to zh-CN.
} catch(error) {
let err: BusinessError = error as BusinessError;
console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
console.error(`call System.setSystemLocale failed, error code: ${err.code}, message: ${err.message}.`);
}
```
......@@ -463,7 +463,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
let is24HourClock: boolean = I18n.System.is24HourClock(); // Check whether the 24-hour clock is enabled.
} catch(error) {
let err: BusinessError = error as BusinessError;
console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
console.error(`call System.is24HourClock failed, error code: ${err.code}, message: ${err.message}.`);
}
```
......@@ -502,7 +502,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
I18n.System.set24HourClock(true);
} catch(error) {
let err: BusinessError = error as BusinessError;
console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
console.error(`call System.set24HourClock failed, error code: ${err.code}, message: ${err.message}.`);
}
```
......@@ -544,7 +544,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
I18n.System.addPreferredLanguage(language, index); // Add zh-CN to the first place in the preferred language list.
} catch(error) {
let err: BusinessError = error as BusinessError;
console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
console.error(`call System.addPreferredLanguage failed, error code: ${err.code}, message: ${err.message}.`);
}
```
......@@ -584,7 +584,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
I18n.System.removePreferredLanguage(index);
} catch(error) {
let err: BusinessError = error as BusinessError;
console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
console.error(`call System.removePreferredLanguage failed, error code: ${err.code}, message: ${err.message}.`);
}
```
......@@ -618,7 +618,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
let preferredLanguageList: Array<string> = I18n.System.getPreferredLanguageList(); // Obtain the current preferred language list.
} catch(error) {
let err: BusinessError = error as BusinessError;
console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
console.error(`call System.getPreferredLanguageList failed, error code: ${err.code}, message: ${err.message}.`);
}
```
......@@ -652,7 +652,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
let firstPreferredLanguage: string = I18n.System.getFirstPreferredLanguage(); // Obtain the first language in the preferred language list.
} catch(error) {
let err: BusinessError = error as BusinessError;
console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
console.error(`call System.getFirstPreferredLanguage failed, error code: ${err.code}, message: ${err.message}.`);
}
```
......@@ -686,7 +686,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
let appPreferredLanguage: string = I18n.System.getAppPreferredLanguage(); // Obtain the preferred language of an application.
} catch(error) {
let err: BusinessError = error as BusinessError;
console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
console.error(`call System.getAppPreferredLanguage failed, error code: ${err.code}, message: ${err.message}.`);
}
```
......@@ -724,7 +724,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
I18n.System.setUsingLocalDigit(true); // Enable the local digit switch.
} catch(error) {
let err: BusinessError = error as BusinessError;
console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
console.error(`call System.setUsingLocalDigit failed, error code: ${err.code}, message: ${err.message}.`);
}
```
......@@ -758,7 +758,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
let status: boolean = I18n.System.getUsingLocalDigit(); // Check whether the local digit switch is enabled.
} catch(error) {
let err: BusinessError = error as BusinessError;
console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
console.error(`call System.getUsingLocalDigit failed, error code: ${err.code}, message: ${err.message}.`);
}
```
......@@ -1913,7 +1913,7 @@ Converts the input string from the source format to the target format.
static isDigit(char: string): boolean
Checks whether the input character string is composed of digits.
Checks whether the input string is composed of digits.
**System capability**: SystemCapability.Global.I18n
......@@ -2121,7 +2121,7 @@ Checks whether the input character is an uppercase letter.
static getType(char: string): string
Obtains the category value of the input character string.
Obtains the category value of the input string.
**System capability**: SystemCapability.Global.I18n
......@@ -2203,7 +2203,7 @@ Converts one measurement unit into another and formats the unit based on the spe
| Type | Description |
| ------ | ----------------------- |
| string | Character string obtained after formatting based on the measurement unit specified by **toUnit**.|
| string | string obtained after formatting based on the measurement unit specified by **toUnit**.|
**Example**
```ts
......@@ -2371,7 +2371,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
let sortedLanguages: Array<I18n.LocaleItem> = systemLocaleManager.getLanguageInfoArray(languages, sortOptions);
} catch(error) {
let err: BusinessError = error as BusinessError;
console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
console.error(`call systemLocaleManager.getLanguageInfoArray failed, error code: ${err.code}, message: ${err.message}.`);
}
```
......@@ -2420,7 +2420,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
let sortedRegions: Array<I18n.LocaleItem> = systemLocaleManager.getRegionInfoArray(regions, sortOptions);
} catch(error) {
let err: BusinessError = error as BusinessError;
console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
console.error(`call systemLocaleManager.getRegionInfoArray failed, error code: ${err.code}, message: ${err.message}.`);
}
```
......@@ -2452,7 +2452,7 @@ Obtains the array of time zone city items after sorting.
}
} catch(error) {
let err: BusinessError = error as BusinessError;
console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
console.error(`call SystemLocaleManager.getTimeZoneCityItemArray failed, error code: ${err.code}, message: ${err.message}.`);
}
```
......@@ -2837,7 +2837,7 @@ This API is supported since API version 8 and is deprecated since API version 9.
| Type | Description |
| ------ | ----------------------- |
| string | Character string obtained after formatting based on the measurement unit specified by **toUnit**.|
| string | string obtained after formatting based on the measurement unit specified by **toUnit**.|
## Character<sup>(deprecated)</sup>
......@@ -2847,7 +2847,7 @@ This API is supported since API version 8 and is deprecated since API version 9.
static isDigit(char: string): boolean
Checks whether the input character string is composed of digits.
Checks whether the input string is composed of digits.
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [isDigit](#isdigit9).
......@@ -3031,7 +3031,7 @@ This API is supported since API version 8 and is deprecated since API version 9.
static getType(char: string): string
Obtains the type of the input character string.
Obtains the type of the input string.
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [getType](#gettype9).
......
......@@ -3,21 +3,20 @@
The **inputConsumer** module implements listening for combination key events.
> **NOTE**
>
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs provided by this module are system APIs.
## Modules to Import
```js
import inputConsumer from '@ohos.multimodalInput.inputConsumer';
```
## inputConsumer.on
on(type: "key", keyOptions: KeyOptions, callback: Callback&lt;KeyOptions&gt;): void
on(type: 'key', keyOptions: KeyOptions, callback: Callback&lt;KeyOptions&gt;): void
Enables listening for combination key events. This API uses an asynchronous callback to return the combination key data when a combination key event that meets the specified condition occurs.
......@@ -48,7 +47,7 @@ try {
## inputConsumer.off
off(type: "key", keyOptions: KeyOptions, callback?: Callback&lt;KeyOptions&gt;): void
off(type: 'key', keyOptions: KeyOptions, callback?: Callback&lt;KeyOptions&gt;): void
Disables listening for combination key events.
......@@ -60,14 +59,14 @@ Disables listening for combination key events.
| ---------- | -------------------------- | ---- | ------------------------------- |
| type | string | Yes | Event type. Currently, only **key** is supported. |
| keyOptions | [KeyOptions](#keyoptions) | Yes | Combination key options. |
| callback | Callback&lt;KeyOptions&gt; | No | Callback for which listening is disabled. If this parameter is not specified, listening will be disabled for all callbacks registered by the current application.|
| callback | Callback&lt;KeyOptions&gt; | No | Callback to unregister. If this parameter is not specified, listening will be disabled for all callbacks registered by the current application.|
**Example**
```js
let leftAltKey = 2045;
let tabKey = 2049;
// Disable listening for a single callback function.
// Disable listening for a single callback.
let callback = function (keyOptions) {
console.log(`keyOptions: ${JSON.stringify(keyOptions)}`);
}
......@@ -83,7 +82,7 @@ try {
```js
let leftAltKey = 2045;
let tabKey = 2049;
// Disable listening for all callback functions.
// Disable listening for all callbacks.
let callback = function (keyOptions) {
console.log(`keyOptions: ${JSON.stringify(keyOptions)}`);
}
......@@ -97,7 +96,6 @@ try {
}
```
## KeyOptions
Represents combination key options.
......@@ -106,7 +104,7 @@ Represents combination key options.
| Name | Type | Readable | Writable | Description |
| --------- | ------ | ---- | ---- | ------- |
| preKeys | Array<number> | Yes | No| Front key set. The number of front keys ranges from 0 to 4. There is no requirement on the sequence of the keys.|
| finalKey | number | Yes | No| Final key. This parameter is mandatory. A callback function is triggered by the final key.|
| isFinalKeyDown | boolean | Yes | No| Whether the final key is pressed.|
| finalKeyDownDuration | number | Yes | No| Duration within which the final key is pressed. If the value is **0**, the callback function is triggered immediately. If the value is greater than **0** and the value of **isFinalKeyDown** is **true**, the callback function is triggered when the key press duration is longer than the value of this parameter. If the value of **isFinalKeyDown** is **false**, the callback function is triggered when the duration from key press to key release is less than the value of this parameter. |
| preKeys | Array\<number> | Yes | No| Preceding key set. The number of preceding keys ranges from 0 to 4. There is no requirement on the sequence of the keys.<br>For example, in the combination keys **Ctrl+Alt+A**, **Ctrl+Alt** are called preceding keys.|
| finalKey | number | Yes | No| Final key. This parameter is mandatory. A callback is triggered by the final key.<br>For example, in the combination keys **Ctrl+Alt+A**, **A** is called the final key.|
| isFinalKeyDown | boolean | Yes | No| Whether the final key is pressed.<br>The value **true** indicates that the key is pressed, and the value **false** indicates the opposite.|
| finalKeyDownDuration | number | Yes | No| Duration for pressing a key, in μs.<br>If the value of this field is **0**, a callback is triggered immediately.<br>If the value of this field is greater than **0** and **isFinalKeyDown** is **true**, a callback is triggered when the key keeps being pressed after the specified duration expires. If **isFinalKeyDown** is **false**, a callback is triggered when the key is released before the specified duration expires. |
# @ohos.multimodalInput.inputEvent (Input Event)
The **inputEvent** module describes basic events reported by an input device.
The **inputEvent** module provides the basic events reported by the device.
> **NOTE**<br>
> **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
......@@ -13,16 +14,14 @@ import InputEvent from '@ohos.multimodalInput.inputEvent';
## InputEvent
Defines an input event.
Represents an input event.
**System capability**: SystemCapability.MultimodalInput.Input.Core
**Parameters**
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| id | number | Yes| No| Unique event ID generated by the server.|
| deviceId | number | Yes| No| ID of the device that reports the input event.|
| actionTime | number | Yes| No| Time when the event is reported.|
| screenId | number | Yes| No| ID of the target screen.|
| windowId | number | Yes| No| ID of the target window.|
| Name | Type | Readable | Writable | Description |
| ---------- | ------ | ---- | ---- | -------------- |
| id | number | Yes | No | Event ID.|
| deviceId | number | Yes | No | ID of the device that reports the input event. |
| actionTime | number | Yes | No | Time when the input event is reported. |
| screenId | number | Yes | No | ID of the target screen. |
| windowId | number | Yes | No | ID of the target window. |
# @ohos.multimodalInput.inputEventClient (Key Event Injection)
# @ohos.multimodalInput.inputEventClient (Key Injection)
The **inputEventClient** module implements injection of key events.
> **NOTE**
>
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs provided by this module are system APIs.
## Modules to Import
```js
import inputEventClient from '@ohos.multimodalInput.inputEventClient';
```
## inputEventClient.injectEvent
injectEvent({KeyEvent: KeyEvent}): void
Injects a key event. Currently, key injection is supported only for the **Back** key (key value 2).
Injects a key event. Currently, this API applies only to the **/KEYCODE_BACK** key (key value 2).
**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator
......@@ -53,7 +52,6 @@ try {
}
```
## KeyEvent
Represents information about the key event to inject.
......@@ -62,7 +60,7 @@ Represents information about the key event to inject.
| Name | Type | Readable | Writable | Description |
| --------- | ------ | ---- | ---- | ------- |
| isPressed | boolean | Yes | No| Whether the key is pressed. |
| keyCode | number | Yes | No| Key value. Currently, only the **Back** key is supported.|
| keyDownDuration | number | Yes | No| Duration within which the key is pressed. |
| isIntercepted | boolean | Yes | No| Whether the key can be intercepted. |
| isPressed | boolean | Yes | No| Whether the key is pressed.<br>The value **true** indicates that the key is pressed, and the value **false** indicates the opposite. |
| keyCode | number | Yes | No| Keycode value. Currently, only the **KEYCODE_BACK** key is supported.|
| keyDownDuration | number | Yes | No| Duration for pressing a key, in μs. |
| isIntercepted | boolean | Yes | No| Whether the key event can be intercepted.<br>The value **true** indicates that the key event can be intercepted, and the value **false** indicates the opposite.|
# @ohos.multimodalInput.inputMonitor (Input Monitor)
The **inputMonitor** module implements listening for events of input devices (namely, touchscreen and mouse).
The **inputMonitor** module implements listening for events of input devices, including the touchscreen, mouse, touchpad, etc.
> **NOTE**
>**NOTE**
>
> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs provided by this module are system APIs.
>- The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
>- The APIs provided by this module are system APIs.
>
>- In this document, **global** indicates the entire touchscreen or touchpad. For example, listening for global touch events means to listen for touch events of the entire touchpad when a user touches at any position on the touchpad.
## Modules to Import
```js
import inputMonitor from '@ohos.multimodalInput.inputMonitor';
```
## inputMonitor.on('touch')
## inputMonitor.on
on(type: "touch", receiver: TouchEventReceiver): void
on(type: 'touch', receiver: TouchEventReceiver): void
Enables listening for global touch events.
Enables listening for global touch (touchscreen) events.
**Required permissions**: ohos.permission.INPUT_MONITORING
......@@ -30,14 +30,14 @@ Enables listening for global touch events.
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ------------------- |
| type | string | Yes | Type of the input device event. The value is **touch**.|
| receiver | [TouchEventReceiver](#toucheventreceiver) | Yes | Callback used to return the touch event.|
| type | string | Yes | Event type. This field has a fixed value of **touch**.|
| receiver | [TouchEventReceiver](#toucheventreceiver) | Yes | Callback used to return the touch event asynchronously.|
**Example**
```js
try {
inputMonitor.on("touch", (touchEvent) => {
inputMonitor.on('touch', (touchEvent) => {
console.log(`Monitor on success ${JSON.stringify(touchEvent)}`);
return false;
});
......@@ -46,9 +46,9 @@ try {
}
```
## inputMonitor.on<sup>9+</sup>
## inputMonitor.on('mouse')<sup>9+</sup>
on(type: "mouse", receiver: Callback&lt;MouseEvent&gt;): void
on(type: 'mouse', receiver: Callback&lt;MouseEvent&gt;): void
Enables listening for global mouse events.
......@@ -60,14 +60,14 @@ Enables listening for global mouse events.
| Name | Type | Mandatory | Description |
| -------- | -------------------------- | ---- | ------------------- |
| type | string | Yes | Type of the input device event. The value is **mouse**.|
| receiver | Callback&lt;MouseEvent&gt; | Yes | Callback used to return the mouse event. |
| type | string | Yes | Event type. This field has a fixed value of **mouse**.|
| receiver | Callback&lt;MouseEvent&gt; | Yes | Callback used to return the mouse event asynchronously. |
**Example**
```js
try {
inputMonitor.on("mouse", (mouseEvent) => {
inputMonitor.on('mouse', (mouseEvent) => {
console.log(`Monitor on success ${JSON.stringify(mouseEvent)}`);
return false;
});
......@@ -76,13 +76,11 @@ try {
}
```
## inputMonitor.off('touch')
off(type: 'touch', receiver?: TouchEventReceiver): void
## inputMonitor.off
off(type: "touch", receiver?: TouchEventReceiver): void
Disables listening for global touch events.
Disables listening for global touch (touchscreen) events.
**Required permissions**: ohos.permission.INPUT_MONITORING
......@@ -92,20 +90,20 @@ Disables listening for global touch events.
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ------------------- |
| type | string | Yes | Type of the input device event. The value is **touch**.|
| type | string | Yes | Event type. This field has a fixed value of **touch**.|
| receiver | [TouchEventReceiver](#toucheventreceiver) | No | Callback for which listening is disabled. If this parameter is not specified, listening will be disabled for all callbacks registered by the current application. |
**Example**
```js
// Disable listening for a single callback function.
// Disable listening for a single callback.
function callback(touchEvent) {
console.log(`Monitor on success ${JSON.stringify(touchEvent)}`);
return false;
};
try {
inputMonitor.on("touch", callback);
inputMonitor.off("touch", callback);
inputMonitor.on('touch', callback);
inputMonitor.off('touch', callback);
console.log(`Monitor off success`);
} catch (error) {
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
......@@ -113,25 +111,25 @@ try {
```
```js
// Cancel listening for all callback functions.
// Cancel listening for all callbacks.
function callback(touchEvent) {
console.log(`Monitor on success ${JSON.stringify(touchEvent)}`);
return false;
};
try {
inputMonitor.on("touch", callback);
inputMonitor.off("touch");
inputMonitor.on('touch', callback);
inputMonitor.off('touch');
console.log(`Monitor off success`);
} catch (error) {
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputMonitor.off<sup>9+</sup>
## inputMonitor.off('mouse')<sup>9+</sup>
off(type: "mouse", receiver?: Callback&lt;MouseEvent&gt;): void
off(type: 'mouse', receiver?: Callback&lt;MouseEvent&gt;): void
Stops listening for global mouse events.
Disables listening for global mouse events.
**Required permissions**: ohos.permission.INPUT_MONITORING
......@@ -141,7 +139,7 @@ Stops listening for global mouse events.
| Name | Type | Mandatory | Description |
| -------- | -------------------------- | ---- | ------------------- |
| type | string | Yes | Type of the input device event. The value is **mouse**.|
| type | string | Yes | Event type. This field has a fixed value of **mouse**.|
| receiver | Callback&lt;MouseEvent&gt; | No | Callback for which listening is disabled. If this parameter is not specified, listening will be disabled for all callbacks registered by the current application.|
**Example**
......@@ -153,8 +151,8 @@ function callback(mouseEvent) {
return false;
};
try {
inputMonitor.on("mouse", callback);
inputMonitor.off("mouse", callback);
inputMonitor.on('mouse', callback);
inputMonitor.off('mouse', callback);
console.log(`Monitor off success`);
} catch (error) {
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
......@@ -162,14 +160,14 @@ try {
```
```js
// Disable listening for all callback functions.
// Disable listening for all callbacks.
function callback(mouseEvent) {
console.log(`Monitor on success ${JSON.stringify(mouseEvent)}`);
return false;
};
try {
inputMonitor.on("mouse", callback);
inputMonitor.off("mouse");
inputMonitor.on('mouse', callback);
inputMonitor.off('mouse');
console.log(`Monitor off success`);
} catch (error) {
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
......@@ -178,7 +176,7 @@ try {
## TouchEventReceiver
Represents the callback used to return the touch event.
Defines the callback for touch (touchscreen) events.
**Required permissions**: ohos.permission.INPUT_MONITORING
......@@ -200,7 +198,7 @@ Represents the callback used to return the touch event.
```js
try {
inputMonitor.on("touch", touchEvent => {
inputMonitor.on('touch', touchEvent => {
if (touchEvent.touches.length == 3) {// Three fingers are pressed.
return true;
}
......@@ -210,3 +208,240 @@ try {
console.log(`Monitor on failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputMonitor.on('pinch')<sup>10+</sup>
on(type: 'pinch', receiver: Callback&lt;[Pinch](js-apis-multimodalinput-gestureevent.md#pinch)&gt;): void
Enables listening for global touchpad pinch events.
**Required permissions**: ohos.permission.INPUT_MONITORING
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------------------------- | ---- | ------------------- |
| type | string | Yes | Event type. This field has a fixed value of **pinch**.|
| receiver | Callback&lt;[Pinch](js-apis-multimodalinput-gestureevent.md#pinch)&gt; | Yes | Callback used to return the pinch event asynchronously. |
**Example**
```js
try {
inputMonitor.on('pinch', (pinchEvent) => {
console.log(`Monitor on success ${JSON.stringify(pinchEvent)}`);
return false;
});
} catch (error) {
console.log(`Monitor on failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputMonitor.off('pinch')<sup>10+</sup>
off(type: 'pinch', receiver?: Callback&lt;[Pinch](js-apis-multimodalinput-gestureevent.md#pinch)&gt;): void
Disables listening for global touchpad pinch events.
**Required permissions**: ohos.permission.INPUT_MONITORING
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------------------------- | ---- | ------------------- |
| type | string | Yes | Event type. This field has a fixed value of **pinch**.|
| receiver | Callback&lt;[Pinch](js-apis-multimodalinput-gestureevent.md#pinch)&gt; | No | Callback for which listening is disabled. If this parameter is not specified, listening will be disabled for all callbacks registered by the current application.|
**Example**
```js
// Disable listening for a single callback.
function callback(pinchEvent) {
console.log(`Monitor on success ${JSON.stringify(pinchEvent)}`);
return false;
};
try {
inputMonitor.on('pinch', callback);
inputMonitor.off('pinch', callback);
console.log(`Monitor off success`);
} catch (error) {
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
```js
// Cancel listening for all callbacks.
function callback(pinchEvent) {
console.log(`Monitor on success ${JSON.stringify(pinchEvent)}`);
return false;
};
try {
inputMonitor.on('pinch', callback);
inputMonitor.off('pinch');
console.log(`Monitor off success`);
} catch (error) {
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputMonitor.on('threeFingersSwipe')<sup>10+</sup>
on(type: 'threeFingersSwipe', receiver: Callback&lt;[ThreeFingersSwipe](js-apis-multimodalinput-gestureevent.md#threefingersswipe)&gt;): void
Enables listening for three-finger swipe events.
**Required permissions**: ohos.permission.INPUT_MONITORING
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------------------------- | ---- | ------------------- |
| type | string | Yes | Event type. This field has a fixed value of **threeFingersSwipe**.|
| receiver | Callback&lt;[ThreeFingersSwipe](js-apis-multimodalinput-gestureevent.md#threefingersswipe)&gt; | Yes | Callback used to return the three-finger swipe event asynchronously. |
**Example**
```js
try {
inputMonitor.on('threeFingersSwipe', (threeFingersSwipe) => {
console.log(`Monitor on success ${JSON.stringify(threeFingersSwipe)}`);
return false;
});
} catch (error) {
console.log(`Monitor on failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputMonitor.off('threeFingersSwipe')<sup>10+</sup>
off(type: 'threeFingersSwipe', receiver?: Callback&lt;[ThreeFingersSwipe](js-apis-multimodalinput-gestureevent.md#threefingersswipe)&gt;): void
Disables listening for three-finger swipe events.
**Required permissions**: ohos.permission.INPUT_MONITORING
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------------------------- | ---- | ------------------- |
| type | string | Yes | Event type. This field has a fixed value of **threeFingersSwipe**.|
| receiver | Callback&lt;[ThreeFingersSwipe](js-apis-multimodalinput-gestureevent.md#threefingersswipe)&gt; | No | Callback for which listening is disabled. If this parameter is not specified, listening will be disabled for all callbacks registered by the current application.|
**Example**
```js
// Disable listening for a single callback.
function callback(threeFingersSwipe) {
console.log(`Monitor on success ${JSON.stringify(threeFingersSwipe)}`);
return false;
};
try {
inputMonitor.on('threeFingersSwipe', callback);
inputMonitor.off("threeFingersSwipe", callback);
console.log(`Monitor off success`);
} catch (error) {
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
```js
// Cancel listening for all callbacks.
function callback(threeFingersSwipe) {
console.log(`Monitor on success ${JSON.stringify(threeFingersSwipe)}`);
return false;
};
try {
inputMonitor.on("threeFingersSwipe", callback);
inputMonitor.off("threeFingersSwipe");
console.log(`Monitor off success`);
} catch (error) {
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputMonitor.on('fourFingersSwipe')<sup>10+</sup>
on(type: 'fourFingersSwipe', receiver: Callback&lt;[FourFingersSwipe](js-apis-multimodalinput-gestureevent.md#fourfingersswipe)&gt;): void
Enables listening for four-finger swipe events.
**Required permissions**: ohos.permission.INPUT_MONITORING
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------------------------- | ---- | ------------------- |
| type | string | Yes | Event type. This field has a fixed value of **fourFingersSwipe**.|
| receiver | Callback&lt;[FourFingersSwipe](js-apis-multimodalinput-gestureevent.md#fourfingersswipe)&gt; | Yes | Callback used to return the four-finger swipe event asynchronously. |
**Example**
```js
try {
inputMonitor.on('fourFingersSwipe', (fourFingersSwipe) => {
console.log(`Monitor on success ${JSON.stringify(fourFingersSwipe)}`);
return false;
});
} catch (error) {
console.log(`Monitor on failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputMonitor.off('fourFingersSwipe')<sup>10+</sup>
off(type: 'fourFingersSwipe', receiver?: Callback&lt;[FourFingersSwipe](js-apis-multimodalinput-gestureevent.md#fourfingersswipe)&gt;): void
Disables listening for four-finger swipe events.
**Required permissions**: ohos.permission.INPUT_MONITORING
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------------------------- | ---- | ------------------- |
| type | string | Yes | Event type. This field has a fixed value of **fourFingersSwipe**.|
| receiver | Callback&lt;[FourFingersSwipe](js-apis-multimodalinput-gestureevent.md#fourfingersswipe)&gt; | No | Callback for which listening is disabled. If this parameter is not specified, listening will be disabled for all callbacks registered by the current application.|
**Example**
```js
// Disable listening for a single callback.
function callback(fourFingersSwipe) {
console.log(`Monitor on success ${JSON.stringify(fourFingersSwipe)}`);
return false;
};
try {
inputMonitor.on('fourFingersSwipe', callback);
inputMonitor.off('fourFingersSwipe', callback);
console.log(`Monitor off success`);
} catch (error) {
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
```js
// Cancel listening for all callbacks.
function callback(fourFingersSwipe) {
console.log(`Monitor on success ${JSON.stringify(fourFingersSwipe)}`);
return false;
};
try {
inputMonitor.on('fourFingersSwipe', callback);
inputMonitor.off('fourFingersSwipe');
console.log(`Monitor off success`);
} catch (error) {
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
# @ohos.multimodalInput.keyCode (Key Code)
# @ohos.multimodalInput.keyCode (Keycode)
The **keyCode** module provides keycodes for a key device.
The **keyCode** module provides keycode values for key devices, such as the keyboard, power key, camera key, and the like.
> **NOTE**
>
......@@ -14,7 +14,7 @@ import {KeyCode} from '@ohos.multimodalInput.keyCode';
## KeyCode
Enumerates keycodes.
Keycode value.
**System capability**: SystemCapability.MultimodalInput.Input.Core
......@@ -90,8 +90,8 @@ Enumerates keycodes.
| KEYCODE_TAB | 2049 | Tab key |
| KEYCODE_SPACE | 2050 | Space key |
| KEYCODE_SYM | 2051 | Symbol key |
| KEYCODE_EXPLORER | 2052 | Explorer key, which is used to start the explorer application |
| KEYCODE_ENVELOPE | 2053 | Email key, which is used to start the email application |
| KEYCODE_EXPLORER | 2052 | Explorer key, used to start the explorer application |
| KEYCODE_ENVELOPE | 2053 | Email key, used to start the email application |
| KEYCODE_ENTER | 2054 | Enter key |
| KEYCODE_DEL | 2055 | Delete key |
| KEYCODE_GRAVE | 2056 | Key ` |
......@@ -188,7 +188,7 @@ Enumerates keycodes.
| KEYCODE_FIND | 2623 | Find key |
| KEYCODE_CUT | 2624 | Cut key |
| KEYCODE_HELP | 2625 | Help key |
| KEYCODE_CALC | 2626 | Calc key, which is used to start the calculator application |
| KEYCODE_CALC | 2626 | Calc key, used to start the calculator application |
| KEYCODE_FILE | 2627 | File key |
| KEYCODE_BOOKMARKS | 2628 | Bookmarks key |
| KEYCODE_NEXT | 2629 | Next key |
......@@ -274,7 +274,7 @@ Enumerates keycodes.
| KEYCODE_MESSENGER | 2710 | Messenger key |
| KEYCODE_BRIGHTNESS_TOGGLE | 2711 | Brightness Toggle key |
| KEYCODE_SPELLCHECK | 2712 | Spell Check key |
| KEYCODE_COFFEE | 2713 | Coffee key, which is used to launch screen lock or screen saver |
| KEYCODE_COFFEE | 2713 | Coffee key, used to launch screen lock or screen saver |
| KEYCODE_MEDIA_REPEAT | 2714 | Media Repeat key |
| KEYCODE_IMAGES | 2715 | Images key |
| KEYCODE_BUTTONCONFIG | 2716 | Button Configuration key |
......@@ -293,12 +293,12 @@ Enumerates keycodes.
| KEYCODE_KBDINPUTASSIST_NEXTGROUP | 2729 | Keyboard Input-assisted Next Group key |
| KEYCODE_KBDINPUTASSIST_ACCEPT | 2730 | Keyboard Input-assisted Accept key |
| KEYCODE_KBDINPUTASSIST_CANCEL | 2731 | Keyboard Input-assisted Cancel key |
| KEYCODE_FRONT | 2800 | Front key, which is used to launch the windshield defogger |
| KEYCODE_FRONT | 2800 | Front key, used to launch the windshield defogger |
| KEYCODE_SETUP | 2801 | Setup key |
| KEYCODE_WAKEUP | 2802 | Wakeup key |
| KEYCODE_SENDFILE | 2803 | Send File key |
| KEYCODE_DELETEFILE | 2804 | Delete File key |
| KEYCODE_XFER | 2805 | XFER key, which is used to start file transfer |
| KEYCODE_XFER | 2805 | XFER key, used to start file transfer |
| KEYCODE_PROG1 | 2806 | Program key 1 |
| KEYCODE_PROG2 | 2807 | Program key 2 |
| KEYCODE_MSDOS | 2808 | MS-DOS key |
......
# @ohos.multimodalInput.keyEvent (Key Event)
The **keyEvent** module provides key events reported by an input device.
The **keyEvent** module provides key events reported by input devices.
> **NOTE**<br>
> **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
......@@ -13,7 +14,7 @@ import {Action, Key, KeyEvent} from '@ohos.multimodalInput.keyEvent';
## Action
Defines a key action.
Key event type.
**System capability**: SystemCapability.MultimodalInput.Input.Core
......@@ -32,26 +33,26 @@ Defines a key.
| Name | Type| Readable| Writable| Description |
| ----------- | -------- | ---- | ---- | -------------- |
| code | KeyCode | Yes | No | Keycode. |
| pressedTime | number | Yes | No | Time when the key is pressed.|
| pressedTime | number | Yes | No | Duration for pressing a key, in μs.|
| deviceId | number | Yes | No | ID of the device to which the key belongs. |
## KeyEvent
Defines a key event.
Key event.
**System capability**: SystemCapability.MultimodalInput.Input.Core
| Name | Type| Readable| Writable| Description |
| ----------- | -------- | ---- | ---- | ------------------------------ |
| action | Action | Yes | No | Key action. |
| key | Key | Yes | No | Key for which the event is reported. |
| action | [Action](#action) | Yes | No | Key action. |
| key | [Key](#key) | Yes | No | Key for which the event is reported. |
| unicodeChar | number | Yes | No | Unicode character corresponding to the key. |
| keys | Key[] | Yes | No | List of pressed keys. |
| ctrlKey | boolean | Yes | No | Whether ctrlKey is being pressed. |
| ctrlKey | boolean | Yes | No | Whether ctrlKey is being pressed.<br>The value **true** indicates that the key is pressed, and the value **false** indicates the opposite.|
| altKey | boolean | Yes | No | Whether altKey is being pressed. |
| shiftKey | boolean | Yes | No | Whether shiftKey is being pressed. |
| logoKey | boolean | Yes | No | Whether logoKey is being pressed. |
| fnKey | boolean | Yes | No | Whether fnKey is being pressed. |
| capsLock | boolean | Yes | No | Whether capsLock is active. |
| capsLock | boolean | Yes | No | Whether capsLock is active.<br>The value **true** indicates that capsLock is active, and the value **false** indicates the opposite. |
| numLock | boolean | Yes | No | Whether numLock is active. |
| scrollLock | boolean | Yes | No | Whether scrollLock is active.|
......@@ -2,7 +2,8 @@
The **mouseEvent** module provides mouse events reported by an input device.
> **NOTE**<br>
> **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
......@@ -13,7 +14,7 @@ import { Action, Button, Axis, AxisValue, MouseEvent } from '@ohos.multimodalInp
## Action
Defines a mouse action.
Enumerates mouse event types.
**System capability**: SystemCapability.MultimodalInput.Input.Core
......@@ -27,10 +28,9 @@ Defines a mouse action.
| AXIS_UPDATE | 5 | Updating of the axis event associated with the mouse.|
| AXIS_END | 6 | Ending of the axis event associated with the mouse.|
## Button
Enumerates mouse actions.
Enumerates mouse buttons.
**System capability**: SystemCapability.MultimodalInput.Input.Core
......@@ -60,7 +60,7 @@ Enumerates mouse axis types.
## AxisValue
Defines a mouse axis type and value.
Defines the mouse axis type and axis value.
**System capability**: SystemCapability.MultimodalInput.Input.Core
......@@ -72,28 +72,28 @@ Defines a mouse axis type and value.
## MouseEvent
Defines a mouse event.
Defines the mouse event.
**System capability**: SystemCapability.MultimodalInput.Input.Core
| Name | Type | Readable | Writable | Description |
| -------------- | ----------- | ---- | ---- | ---------------------------------------- |
| action | Action | Yes | No | Mouse event action. |
| action | [Action](#action) | Yes | No | Mouse event action. |
| screenX | number | Yes | No | Horizontal coordinate of the mouse pointer on the screen. |
| screenY | number | Yes | No | Vertical coordinate of the mouse pointer on the screen. |
| windowX | number | Yes | No | Horizontal coordinate of the mouse pointer in the window. |
| windowY | number | Yes | No | Vertical coordinate of the mouse pointer in the window. |
| rawDeltaX | number | Yes | No | Horizontal coordinate offset relative to the previous reported mouse pointer position.|
| rawDeltaY | number | Yes | No | Vertical coordinate offset relative to the previous reported mouse pointer position. |
| button | Button | Yes | No | Mouse button
| button | [Button](#button) | Yes | No | Mouse button
| pressedButtons | Button[] | Yes | No | Button being pressed. |
| axes | AxisValue[] | Yes | No | All axis data contained in the event. |
| pressedKeys | KeyCode[] | Yes | No | List of pressed keys. |
| ctrlKey | boolean | Yes | No | Whether ctrlKey is being pressed. |
| ctrlKey | boolean | Yes | No | Whether ctrlKey is being pressed.<br>The value **true** indicates that the key is pressed, and the value **false** indicates the opposite. |
| altKey | boolean | Yes | No | Whether altKey is being pressed. |
| shiftKey | boolean | Yes | No | Whether shiftKey is being pressed. |
| logoKey | boolean | Yes | No | Whether logoKey is being pressed. |
| fnKey | boolean | Yes | No | Whether fnKey is being pressed. |
| capsLock | boolean | Yes | No | Whether capsLock is active. |
| capsLock | boolean | Yes | No | Whether capsLock is active.<br>The value **true** indicates that capsLock is active, and the value **false** indicates the opposite. |
| numLock | boolean | Yes | No | Whether numLock is active. |
| scrollLock | boolean | Yes | No | Whether scrollLock is active. |
......@@ -5,6 +5,7 @@ The **shortKey** module provides APIs to set the delay for starting an ability u
> **NOTE**
>
> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs provided by this module are system APIs.
## Modules to Import
......@@ -17,7 +18,7 @@ import shortKey from '@ohos.multimodalInput.shortKey';
setKeyDownDuration(businessKey: string, delay: number, callback: AsyncCallback&lt;void&gt;): void
Sets the delay for starting an ability using the shortcut key. This API uses an asynchronous callback to return the result.
Sets the delay for starting an ability using shortcut keys. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.ShortKey
......@@ -26,8 +27,8 @@ Sets the delay for starting an ability using the shortcut key. This API uses an
| Name | Type | Mandatory| Description |
| ---------- | ------------------- | ---- | ------------------------------------------------------------ |
| businessKey| string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file.|
| delay | number | Yes | Delay for starting an ability using the shortcut key, in ms.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
| delay | number | Yes | Delay for starting an ability using shortcut keys, in milliseconds. This field is invalid only when shortcut keys are used.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object. |
**Example**
......@@ -45,13 +46,11 @@ try {
}
```
## shortKey.setKeyDownDuration
setKeyDownDuration(businessKey: string, delay: number): Promise&lt;void&gt;
Sets the delay for starting an ability using the shortcut key. This API uses a promise to return the result.
Sets the delay for starting an ability using shortcut keys. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.ShortKey
......@@ -60,13 +59,13 @@ Sets the delay for starting an ability using the shortcut key. This API uses a p
| Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | ------------------------------------------------------------ |
| businessKey| string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file.|
| delay | number | Yes | Delay for starting an ability using the shortcut key, in ms.|
| delay | number | Yes | Delay for starting an ability using shortcut keys, in milliseconds. This field is invalid only when shortcut keys are used.|
**Return value**
| Parameters | Description |
| ------------- | ------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
......
......@@ -1262,7 +1262,7 @@ Obtains the file descriptor of the **TCPSocket** object. This API uses an asynch
```js
import socket from "@ohos.net.socket";
var tcp = socket.constructTCPSocketInstance();
let tcp = socket.constructTCPSocketInstance();
let tunnelfd = 0
tcp.bind({
address: "0.0.0.0",
......@@ -1302,7 +1302,7 @@ Obtains the file descriptor of the **TCPSocket** object. This API uses a promise
```js
import socket from "@ohos.net.socket";
var tcp = socket.constructTCPSocketInstance();
let tcp = socket.constructTCPSocketInstance();
let tunnelfd = 0
tcp.bind({
address: "0.0.0.0",
......@@ -1715,7 +1715,7 @@ Binds the IP address and port number. The port number can be specified or random
| 2303109 | Bad file number. |
| 2303111 | Resource temporarily unavailable try again. |
| 2303198 | Address already in use. |
| 2303199 | Cannot assign requested address. |
| 2303199 | Address not available. |
**Example**
......@@ -1765,7 +1765,7 @@ Binds the IP address and port number. The port number can be specified or random
| 2303109 | Bad file number. |
| 2303111 | Resource temporarily unavailable try again. |
| 2303198 | Address already in use. |
| 2303199 | Cannot assign requested address. |
| 2303199 | Address not available. |
**Example**
......@@ -1805,7 +1805,7 @@ Obtains the status of the TCPSocketServer connection. This API uses an asynchron
| 401 | Parameter error. |
| 201 | Permission denied. |
| 2300002 | System internal error. |
| 2303188 | Socket operation on non-socket. |
| 2303188 | Not a socket. |
**Example**
......@@ -1852,7 +1852,7 @@ Obtains the status of the TCPSocketServer connection. This API uses a promise to
| -------- | ------------------------------- |
| 201 | Permission denied. |
| 2300002 | System internal error. |
| 2303188 | Socket operation on non-socket. |
| 2303188 | Not a socket. |
**Example**
......@@ -1899,7 +1899,7 @@ Sets other properties of the TCPSocketServer connection. This API uses an asynch
| 401 | Parameter error. |
| 201 | Permission denied. |
| 2300002 | System internal error. |
| 2303188 | Socket operation on non-socket. |
| 2303188 | Not a socket. |
**Example**
......@@ -1962,7 +1962,7 @@ Sets other properties of the TCPSocketServer connection. This API uses a promise
| 401 | Parameter error. |
| 201 | Permission denied. |
| 2300002 | System internal error. |
| 2303188 | Socket operation on non-socket. |
| 2303188 | Not a socket. |
**Example**
......@@ -2338,7 +2338,7 @@ Obtains the remote address of a socket connection. This API uses an asynchronous
| 401 | Parameter error. |
| 201 | Permission denied. |
| 2300002 | System internal error. |
| 2303188 | Socket operation on non-socket. |
| 2303188 | Not a socket. |
**Example**
......@@ -2380,7 +2380,7 @@ Obtains the remote address of a socket connection. This API uses a promise to re
| -------- | ------------------------------- |
| 201 | Permission denied. |
| 2300002 | System internal error. |
| 2303188 | Socket operation on non-socket. |
| 2303188 | Not a socket. |
**Example**
......@@ -2751,7 +2751,7 @@ Obtains the status of the TLS socket connection. This API uses an asynchronous c
| ID| Error Message |
| ------- | ------------------------------ |
| 2303188 | Socket operation on non-socket.|
| 2303188 | Not a socket.|
| 2300002 | System internal error. |
**Example**
......@@ -2791,7 +2791,7 @@ Obtains the status of the TLS socket connection. This API uses a promise to retu
| ID| Error Message |
| ------- | ------------------------------ |
| 2303188 | Socket operation on non-socket.|
| 2303188 | Not a socket.|
| 2300002 | System internal error. |
**Example**
......@@ -2831,7 +2831,7 @@ Sets other properties of the TCP socket connection after **bind** is successfull
| ID| Error Message |
| ------- | ----------------------------- |
| 401 | Parameter error. |
| 2303188 | Socket operation on non-socket.|
| 2303188 | Not a socket.|
| 2300002 | System internal error. |
**Example**
......@@ -2888,7 +2888,7 @@ Sets other properties of the TCP socket connection after **bind** is successfull
| ID| Error Message |
| ------- | ------------------------------ |
| 401 | Parameter error. |
| 2303188 | Socket operation on non-socket.|
| 2303188 | Not a socket.|
| 2300002 | System internal error. |
**Example**
......@@ -2936,6 +2936,7 @@ Subscribes to **message** events of the TLS socket connection. This API uses an
**Example**
```js
import socket from '@ohos.net.socket';
let tls = socket.constructTLSSocketInstance();
let messageView = '';
tls.on('message', value => {
......@@ -2970,6 +2971,7 @@ Unsubscribes from **message** events of the TLS socket connection. This API uses
**Example**
```js
import socket from '@ohos.net.socket';
let tls = socket.constructTLSSocketInstance();
let messageView = '';
let callback = value => {
......@@ -3003,6 +3005,7 @@ Subscribes to **connect** or **close** events of the TLS socket connection. This
**Example**
```js
import socket from '@ohos.net.socket';
let tls = socket.constructTLSSocketInstance();
tls.on('connect', () => {
console.log("on connect success")
......@@ -3033,6 +3036,7 @@ Unsubscribes from **connect** or **close** events of the TLS socket connection.
**Example**
```js
import socket from '@ohos.net.socket';
let tls = socket.constructTLSSocketInstance();
let callback1 = () => {
console.log("on connect success");
......@@ -3067,6 +3071,7 @@ Subscribes to **error** events of the TLS socket connection. This API uses an as
**Example**
```js
import socket from '@ohos.net.socket';
let tls = socket.constructTLSSocketInstance();
tls.on('error', err => {
console.log("on error, err:" + JSON.stringify(err))
......@@ -3094,6 +3099,7 @@ Unsubscribes from **error** events of the TLS socket connection. This API uses a
**Example**
```js
import socket from '@ohos.net.socket';
let tls = socket.constructTLSSocketInstance();
let callback = err => {
console.log("on error, err:" + JSON.stringify(err));
......@@ -3126,10 +3132,10 @@ Sets up a TLS socket connection, and creates and initializes a TLS session after
| 2303104 | Interrupted system call. |
| 2303109 | Bad file number. |
| 2303111 | Resource temporarily unavailable try again. |
| 2303188 | Socket operation on non-socket. |
| 2303188 | Not a socket. |
| 2303191 | Protocol wrong type for socket. |
| 2303198 | Address already in use. |
| 2303199 | Cannot assign requested address. |
| 2303199 | Address not available. |
| 2303210 | Connection timed out. |
| 2303501 | SSL is null. |
| 2303502 | Error in tls reading. |
......@@ -3225,10 +3231,10 @@ Sets up a TLS socket connection, and creates and initializes a TLS session after
| 2303104 | Interrupted system call. |
| 2303109 | Bad file number. |
| 2303111 | Resource temporarily unavailable try again. |
| 2303188 | Socket operation on non-socket. |
| 2303188 | Not a socket. |
| 2303191 | Protocol wrong type for socket. |
| 2303198 | Address already in use. |
| 2303199 | Cannot assign requested address. |
| 2303199 | Address not available. |
| 2303210 | Connection timed out. |
| 2303501 | SSL is null. |
| 2303502 | Error in tls reading. |
......@@ -3316,7 +3322,7 @@ Obtains the remote address of a TLS socket connection. This API uses an asynchro
| ID| Error Message |
| ------- | ----------------------------- |
| 2303188 | Socket operation on non-socket.|
| 2303188 | Not a socket.|
| 2300002 | System internal error. |
**Example**
......@@ -3349,7 +3355,7 @@ Obtains the remote address of a TLS socket connection. This API uses a promise t
| ID| Error Message |
| ------- | ------------------------------ |
| 2303188 | Socket operation on non-socket.|
| 2303188 | Not a socket.|
| 2300002 | System internal error. |
**Example**
......@@ -3937,7 +3943,7 @@ Listens to client connections after **bind** is successfully called. This API us
| 2303109 | Bad file number. |
| 2303111 | Resource temporarily unavailable try again. |
| 2303198 | Address already in use. |
| 2303199 | Cannot assign requested address. |
| 2303199 | Address not available. |
| 2303501 | SSL is null. |
| 2303502 | Error in tls reading. |
| 2303503 | Error in tls writing |
......@@ -4003,7 +4009,7 @@ Listens to client connections after **bind** is successfully called. This API us
| 2303109 | Bad file number. |
| 2303111 | Resource temporarily unavailable try again. |
| 2303198 | Address already in use. |
| 2303199 | Cannot assign requested address. |
| 2303199 | Address not available. |
| 2303501 | SSL is null. |
| 2303502 | Error in tls reading. |
| 2303503 | Error in tls writing |
......@@ -4061,7 +4067,7 @@ Obtains the status of the TLS socket server connection upon successful listening
| ID| Error Message |
| -------- | ------------------------------- |
| 401 | Parameter error. |
| 2303188 | Socket operation on non-socket. |
| 2303188 | Not a socket. |
| 2300002 | System internal error. |
**Example**
......@@ -4121,7 +4127,7 @@ Obtains the status of the TLS socket server connection upon successful listening
| ID| Error Message |
| -------- | ------------------------------- |
| 2303188 | Socket operation on non-socket. |
| 2303188 | Not a socket. |
| 2300002 | System internal error. |
**Example**
......@@ -4183,7 +4189,7 @@ Sets other properties of the TLS socket server connection upon successful listen
| ID| Error Message |
| -------- | ------------------------------- |
| 401 | Parameter error. |
| 2303188 | Socket operation on non-socket. |
| 2303188 | Not a socket. |
| 2300002 | System internal error. |
**Example**
......@@ -4258,7 +4264,7 @@ Sets other properties of the TLS socket server connection upon successful listen
| ID| Error Message |
| -------- | ------------------------------- |
| 401 | Parameter error. |
| 2303188 | Socket operation on non-socket. |
| 2303188 | Not a socket. |
| 2300002 | System internal error. |
**Example**
......@@ -4870,7 +4876,7 @@ Sends a message to the server after a TLS socket server connection is establishe
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------- |
| data | string | Yes | Parameters required for the TLS socket server connection.|
| data | string | Yes | Parameters for sending data over the TLS socket server connection.|
**Return value**
......@@ -5068,7 +5074,7 @@ Obtains the remote address of a TLS socket server connection. This API uses an a
| ID| Error Message |
| -------- | ------------------------------- |
| 401 | Parameter error. |
| 2303188 | Socket operation on non-socket. |
| 2303188 | Not a socket. |
| 2300002 | System internal error. |
**Example**
......@@ -5126,7 +5132,7 @@ Obtains the remote address of a TLS socket server connection. This API uses a pr
| ID| Error Message |
| -------- | ------------------------------- |
| 2303188 | Socket operation on non-socket. |
| 2303188 | Not a socket. |
| 2300002 | System internal error. |
**Example**
......
# @ohos.multimodalInput.touchEvent (Touch Event)
The **touchEvent** module provides touch events reported by an input device.
The **touchEvent** module provides touch (touchscreen) events reported by an input device.
> **NOTE**<br>
> **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
......@@ -13,72 +14,72 @@ import {Action,ToolType,SourceType,Touch,TouchEvent} from '@ohos.multimodalInput
## Action
Enumerates touch actions.
Enumerates touch event types.
**System capability**: SystemCapability.MultimodalInput.Input.Core
| Name | Value | Description |
| ------ | ----- | ----------- |
| CANCEL | 0 | Cancellation of the touch action.|
| DOWN | 1 | Pressing of touch. |
| MOVE | 2 | Moving of touch. |
| UP | 3 | Lifting of touch. |
| ------ | ------ | ---- |
| CANCEL | 0 | Cancellation of touch.|
| DOWN | 1 | Pressing of touch.|
| MOVE | 2 | Moving of touch.|
| UP | 3 | Lifting of touch.|
## ToolType
Enumerates tool types.
Enumerates touch tool types.
**System capability**: SystemCapability.MultimodalInput.Input.Core
| Name | Value | Description |
| ---- | ----- | ----------- |
| FINGER | 0 | Finger|
| PEN | 1 | Pen|
| RUBBER | 2 | Eraser|
| BRUSH | 3 | Brush|
| PENCIL | 4 | Pencil|
| AIRBRUSH | 5 | Air brush|
| MOUSE | 6 | Mouse|
| LENS | 7 | Lens|
| -------- | ------ | ---- |
| FINGER | 0 | Finger |
| PEN | 1 | Stylus |
| RUBBER | 2 | Eraser |
| BRUSH | 3 | Brush |
| PENCIL | 4 | Pencil |
| AIRBRUSH | 5 | Air brush |
| MOUSE | 6 | Mouse |
| LENS | 7 | Lens |
## SourceType
Enumerates source types.
Enumerates touch source types.
**System capability**: SystemCapability.MultimodalInput.Input.Core
| Name | Value | Description |
| ---- | ----- | ----------- |
| TOUCH_SCREEN | 0 | Touchscreen|
| ------------ | ------ | ---- |
| TOUCH_SCREEN | 0 | Touchscreen |
| PEN | 1 | Stylus |
| TOUCH_PAD | 2 | Touchpad |
## Touch
Defines a touch action.
Defines the touch point information.
**System capability**: SystemCapability.MultimodalInput.Input.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| id | number | Yes| No| Pointer ID.|
| pressedTime | number | Yes| No| Time stamp when touch is pressed.|
| screenX | number | Yes| No| X coordinate of the touch position on the screen.|
| screenY | number | Yes| No| Y coordinate of the touch position on the screen.|
| windowX | number | Yes| No| X coordinate of the touch position in the window.|
| windowY | number | Yes| No| Y coordinate of the touch position in the window.|
| pressure | number | Yes| No| Pressure value. The value range is [0.0, 1.0]. The value 0.0 indicates that the pressure is not supported.|
| width | number | Yes| No| Width of the contact area where touch is pressed.|
| height | number | Yes| No| Height of the contact area where touch is pressed.|
| tiltX | number | Yes| No| Angle relative to the YZ plane. The value range is [-90, 90]. A positive value indicates a rightward tilt.|
| tiltY | number | Yes| No| Angle relative to the XZ plane. The value range is [-90, 90]. A positive value indicates a downward tilt.|
| toolX | number | Yes| No| Center point X of the tool area.|
| toolY | number | Yes| No| Center point Y of the tool area.|
| toolWidth | number | Yes| No| Width of the tool area.|
| toolHeight | number | Yes| No| Height of the tool area.|
| rawX | number | Yes| No| X coordinate of the input device.|
| rawY | number | Yes| No| Y coordinate of the input device.|
| toolType | ToolType | Yes| No| Tool type.|
| Name | Type | Readable | Writable | Description |
| ----------- | ------ | ---- | ---- | ----------------------------------- |
| id | number | Yes | No | Touch event ID. |
| pressedTime | number | Yes | No | Press timestamp, in μs. |
| screenX | number | Yes | No | X coordinate of the touch position on the screen. |
| screenY | number | Yes | No | Y coordinate of the touch position on the screen. |
| windowX | number | Yes | No | X coordinate of the touch position in the window. |
| windowY | number | Yes | No | Y coordinate of the touch position in the window. |
| pressure | number | Yes | No | Pressure value. The value range is [0.0, 1.0]. The value 0.0 indicates that the pressure is not supported. |
| width | number | Yes | No | Width of the touch area. |
| height | number | Yes | No | Height of the touch area. |
| tiltX | number | Yes | No | Angle relative to the YZ plane. The value range is [-90, 90]. A positive value indicates a rightward tilt.|
| tiltY | number | Yes | No | Angle relative to the XZ plane. The value range is [-90, 90]. A positive value indicates a downward tilt.|
| toolX | number | Yes | No | X coordinate of the center point of the tool area. |
| toolY | number | Yes | No | Y coordinate of the center point of the tool area. |
| toolWidth | number | Yes | No | Width of the tool area. |
| toolHeight | number | Yes | No | Height of the tool area. |
| rawX | number | Yes | No | X coordinate of the input device. |
| rawY | number | Yes | No | Y coordinate of the input device. |
| toolType | [ToolType](#tooltype) | Yes | No | Tool type. |
## TouchEvent
......@@ -86,9 +87,9 @@ Defines a touch event.
**System capability**: SystemCapability.MultimodalInput.Input.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| action | Action | Yes| No| Touch action.|
| touch | Touch | Yes| No| Current touch point.|
| touches | Touch[] | Yes| No| All touch points.|
| sourceType | SourceType | Yes| No| Device type of the touch source.|
| Name | Type | Readable | Writable | Description |
| ---------- | ---------- | ---- | ---- | --------- |
| action | [Action](#action) | Yes | No | Touch event type. |
| touch | [Touch](#touch) | Yes | No | Current touch point. |
| touches | Touch[] | Yes | No | All touch points. |
| sourceType | [SourceType](#sourcetype) | Yes | No | Touch source type.|
......@@ -43,7 +43,7 @@ The specified event domain name does not comply with the following rules:
- The event domain name contains only digits, lowercase letters, and underscores (\_).
- The event domain name starts with a lowercase letter and does not end with an underscore (\_).
- The event domain name is not empty and contains a maximum of 32 characters.
- The event domain name is not empty and contains a maximum of 16 characters.
**Solution**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册