未验证 提交 cbfc189f 编写于 作者: O openharmony_ci 提交者: Gitee

!6879 翻译已完成 6097 & 6004

Merge pull request !6879 from shawn_he/0718-31
...@@ -16,17 +16,18 @@ The following table describes APIs available for mutual conversion between coord ...@@ -16,17 +16,18 @@ The following table describes APIs available for mutual conversion between coord
| API | Description | | API | Description |
| -------- | -------- | | -------- | -------- |
| isGeoServiceAvailable(callback: AsyncCallback<boolean>) : void | Checks whether the (reverse) geocoding service is available. This function uses an asynchronous callback to return the result. | | isGeoServiceAvailable(callback: AsyncCallback<boolean>) : void | Checks whether the (reverse) geocoding service is available. This function uses an asynchronous callback to return the result. |
| isGeoServiceAvailable() : Promise<boolean> | Checks whether the (reverse) geocoding service is available. This function uses a promise to return the result. | | isGeoServiceAvailable() : Promise<boolean> | Checks whether the (reverse) geocoding service is available. This function uses a promise to return the result. |
| getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>) : void | Converts coordinates into geographic description through reverse geocoding. This function uses an asynchronous callback to return the result. | | getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>) : void | Converts coordinates into geographic description through reverse geocoding. This function uses an asynchronous callback to return the result. |
| getAddressesFromLocation(request: ReverseGeoCodeRequest) : Promise<Array<GeoAddress>>; | Converts coordinates into geographic description through reverse geocoding. This function uses a promise to return the result. | | getAddressesFromLocation(request: ReverseGeoCodeRequest) : Promise<Array<GeoAddress>>; | Converts coordinates into geographic description through reverse geocoding. This function uses a promise to return the result. |
| getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>) : void | Converts geographic description into coordinates through geocoding. This function uses an asynchronous callback to return the result. | | getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>) : void | Converts geographic description into coordinates through geocoding. This function uses an asynchronous callback to return the result. |
| getAddressesFromLocationName(request: GeoCodeRequest) : Promise<Array<GeoAddress>> | Converts geographic description into coordinates through geocoding. This function uses a promise to return the result. | | getAddressesFromLocationName(request: GeoCodeRequest) : Promise<Array<GeoAddress>> | Converts geographic description into coordinates through geocoding. This function uses a promise to return the result. |
## How to Develop ## How to Develop
> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
>
> The **GeoConvert** instance needs to access backend services to obtain information. Therefore, before performing the following steps, ensure that your device is connected to the network. > The **GeoConvert** instance needs to access backend services to obtain information. Therefore, before performing the following steps, ensure that your device is connected to the network.
1. Import the **geolocation** module by which you can implement all APIs related to the geocoding and reverse geocoding conversion capabilities. 1. Import the **geolocation** module by which you can implement all APIs related to the geocoding and reverse geocoding conversion capabilities.
...@@ -45,7 +46,7 @@ The following table describes APIs available for mutual conversion between coord ...@@ -45,7 +46,7 @@ The following table describes APIs available for mutual conversion between coord
}); });
``` ```
Your application can obtain the **GeoAddress** list that matches the specified coordinates and then read location information from it. For details, see the _API Reference_. Your application can obtain the **GeoAddress** list that matches the specified coordinates and then read location information from it. For details, see [Geolocation](../reference/apis/js-apis-geolocation.md).
- Call **getAddressesFromLocationName** to convert geographic description into coordinates. - Call **getAddressesFromLocationName** to convert geographic description into coordinates.
``` ```
...@@ -55,6 +56,6 @@ The following table describes APIs available for mutual conversion between coord ...@@ -55,6 +56,6 @@ The following table describes APIs available for mutual conversion between coord
}); });
``` ```
Your application can obtain the **GeoAddress** list that matches the specified location information and read coordinates from it. For details, see the _API Reference_. Your application can obtain the **GeoAddress** list that matches the specified location information and read coordinates from it. For details, see [Geolocation](../reference/apis/js-apis-geolocation.md).
To improve the accuracy of location results, you can set the longitude and latitude ranges in **GeoCodeRequest**. To improve the accuracy of location results, you can set the longitude and latitude ranges in **GeoCodeRequest**.
# Combination Key # Combination Key
The input consumer module implements listening for key events.
> **NOTE**<br> > **NOTE**<br>
> >
...@@ -22,23 +23,23 @@ on(type: "key", keyOptions: KeyOptions, callback: Callback&lt;KeyOptions&gt;): v ...@@ -22,23 +23,23 @@ on(type: "key", keyOptions: KeyOptions, callback: Callback&lt;KeyOptions&gt;): v
Enables listening for combination key events. When a combination key event that meets the specified conditions occurs, **KeyOptions** will be passed as an input parameter to **callback**. Enables listening for combination key events. When a combination key event that meets the specified conditions occurs, **KeyOptions** will be passed as an input parameter to **callback**.
**System capability**: SystemCapability.MultimodalInput.Input.InputConsumer This is a system API.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the key input event to listen for. Only **key** is supported.| | type | string | Yes| Type of the key input event to listen for. Only **key** is supported.|
| keyOptions | [KeyOptions](#keyoption) | Yes| Key option, which specifies the condition for combination key input.| | keyOptions | [keyOptions](#keyoptions) | Yes| Key option, which specifies the condition for combination key input.|
| callback | Callback&lt;KeyOptions&gt; | Yes| Callback used to return the result. When a key input event that meets the specified options occurs, **keyOptions** will be passed as an input parameter to **callback**.| | callback | Callback&lt;[keyOptions](#keyoptions)&gt; | Yes| Callback used to return the result. When a key input event that meets the specified options occurs, **keyOptions** will be passed as an input parameter to **callback**.|
**Example** **Example**
``` ```
let keyOptions = { preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0 } let keyOptions = {preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0}
let callback = function (keyOptions) { let callback = function(keyOptions) {
console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey, console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey,
"isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration) "isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration)
} }
inputConsumer.on('key', keyOptions, callback); inputConsumer.on('key', keyOptions, callback);
``` ```
...@@ -50,6 +51,8 @@ off(type: "key", keyOptions: KeyOptions, callback: Callback&lt;KeyOptions&gt;): ...@@ -50,6 +51,8 @@ off(type: "key", keyOptions: KeyOptions, callback: Callback&lt;KeyOptions&gt;):
Stops listening for combination key events. Stops listening for combination key events.
This is a system API.
**System capability**: SystemCapability.MultimodalInput.Input.InputConsumer **System capability**: SystemCapability.MultimodalInput.Input.InputConsumer
**Parameters** **Parameters**
...@@ -57,16 +60,16 @@ Stops listening for combination key events. ...@@ -57,16 +60,16 @@ Stops listening for combination key events.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the key input event to listen for. Only **key** is supported.| | type | string | Yes| Type of the key input event to listen for. Only **key** is supported.|
| keyOptions | [KeyOptions](#keyoption) | Yes| Key options passed to the key input event when listening starts.| | keyOptions | [keyOptions](#keyoptions) | Yes| Key options passed to the key input event when listening starts.|
| callback | Callback&lt;KeyOptions&gt; | Yes| Callback function passed to the key input event with the key options when listening starts.| | callback | Callback&lt;[keyOptions](#keyoptions)&gt; | Yes| Callback function passed to the key input event with the key option when listening starts.|
**Example** **Example**
``` ```
let keyOptions = { preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0 } let keyOptions = {preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0}
let callback = function (keyOptions) { let callback = function(keyOptions) {
console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey, console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey,
"isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration) "isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration)
} }
inputConsumer.off('key', keyOptions, callback); inputConsumer.off('key', keyOptions, callback);
``` ```
...@@ -76,6 +79,8 @@ inputConsumer.off('key', keyOptions, callback); ...@@ -76,6 +79,8 @@ inputConsumer.off('key', keyOptions, callback);
Defines the key options that are met when a combination key input event occurs. Defines the key options that are met when a combination key input event occurs.
This is a system API.
**System capability**: SystemCapability.MultimodalInput.Input.InputConsumer **System capability**: SystemCapability.MultimodalInput.Input.InputConsumer
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
......
...@@ -41,7 +41,7 @@ inputDevice.getDeviceIds((ids)=>{ ...@@ -41,7 +41,7 @@ inputDevice.getDeviceIds((ids)=>{
## inputDevice.getDeviceIds ## inputDevice.getDeviceIds
function getDeviceIds(): Promise<Array\<number>> getDeviceIds(): Promise&lt;Array&lt;number&gt;&gt;
Obtains the IDs of all input devices. This API uses a promise to return the result. Obtains the IDs of all input devices. This API uses a promise to return the result.
...@@ -51,7 +51,7 @@ Obtains the IDs of all input devices. This API uses a promise to return the resu ...@@ -51,7 +51,7 @@ Obtains the IDs of all input devices. This API uses a promise to return the resu
| Parameter | Description | | Parameter | Description |
| ---------------------- | ------------------ | | ---------------------- | ------------------ |
| Promise\<Array\<number>> | Promise used to return the result.| | Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the result.|
**Example** **Example**
...@@ -91,17 +91,23 @@ inputDevice.getDevice(1, (inputDevice)=>{ ...@@ -91,17 +91,23 @@ inputDevice.getDevice(1, (inputDevice)=>{
## inputDevice.getDevice ## inputDevice.getDevice
function getDevice(deviceId: number): Promise\<InputDeviceData> getDevice(deviceId: number): Promise&lt;InputDeviceData&gt;
Obtains the information about an input device. This API uses a promise to return the result. Obtains the information about an input device. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice **System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ------------ |
| deviceId | number | Yes | ID of the input device.|
**Return value** **Return value**
| Parameter | Description | | Parameter | Description |
| ------------------------ | ------------------ | | ------------------------ | ------------------ |
| Promise\<InputDeviceData> | Promise used to return the result.| | Promise&lt;[InputDeviceData](#inputdevicedata)&gt; | Promise used to return the result.|
**Example** **Example**
...@@ -121,21 +127,15 @@ Defines the information about an input device. ...@@ -121,21 +127,15 @@ Defines the information about an input device.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice **System capability**: SystemCapability.MultimodalInput.Input.InputDevice
| Name | Type | Description | | Name | Type | Description |
| ---------- | -------------------------- | ---------------------------------------------------- | | -------------------- | -------------------------------------- | ---------------------------------------- |
| id | number | Unique identifier of an input device. If the same physical device is repeatedly inserted and removed, its ID changes. | | id | number | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes. |
| name | string | Name of the input device. | | name | string | Name of the input device. |
| sources | Array&lt;[SourceType](#sourcetype)&gt; | Source types of the input device. For example, if a keyboard is attached with a touchpad, the device has two input sources: keyboard and touchpad. | | sources | Array&lt;[SourceType](#sourcetype)&gt; | Source type of the input device. For example, if a keyboard is attached with a touchpad, the device has two input sources: keyboard and touchpad.|
| axisRanges | Array&lt;[axisRanges](#axisrange)&gt; | Axis information of the input device. | | axisRanges | Array&lt;[axisRanges](#axisrange)&gt; | Axis information of the input device. |
| bus | number | Bus type of the input device. |
| product | number | Product information of the input device. | ## AxisType<sup>9+</sup>
| vendor | number | Vendor information of the input device. |
| version | number | Version information of the input device. | Defines the axis type of an input device.
| phys | string | Physical address of the input device. |
| uniq | string | Unique ID of the input device. |
## AxisType
Defines the axis type of an input device, which is **NULL**.
## AxisRange ## AxisRange
...@@ -154,7 +154,7 @@ Defines the axis information of an input device. ...@@ -154,7 +154,7 @@ Defines the axis information of an input device.
## SourceType ## SourceType
Enumerates the input source types. For example, if a mouse reports an x-axis event, the source of the x-axis is the mouse. Enumerates the input source types of the axis. For example, if a mouse reports an x-axis event, the source of the x-axis is the mouse.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice **System capability**: SystemCapability.MultimodalInput.Input.InputDevice
......
# Input Event Client # Input Event Client
The input event client provides the key injection capability.
> **NOTE** > **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 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 of this module are system APIs and cannot be called by third-party applications. > - The APIs of this module are system APIs and cannot be called by third-party applications.
## Modules to Import ## Modules to Import
...@@ -22,6 +23,8 @@ injectEvent({KeyEvent: KeyEvent}): void ...@@ -22,6 +23,8 @@ injectEvent({KeyEvent: KeyEvent}): void
Injects a key. Injects a key.
This is a system API.
**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator **System capability**: SystemCapability.MultimodalInput.Input.InputSimulator
**Parameters** **Parameters**
...@@ -47,11 +50,13 @@ let res = inputEventClient.injectEvent({KeyEvent: keyEvent}); ...@@ -47,11 +50,13 @@ let res = inputEventClient.injectEvent({KeyEvent: keyEvent});
Defines the information about the key to inject. Defines the information about the key to inject.
This is a system API.
**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator **System capability**: SystemCapability.MultimodalInput.Input.InputSimulator
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| isPressed | boolean | Yes| Whether the key is pressed.| | isPressed | boolean | Yes| Whether the key is pressed.|
| keyCode | Number | Yes| Key code.| | keyCode | number | Yes | Key code. |
| keyDownDuration | boolean | Yes| Duration for which the key is pressed.| | keyDownDuration | number | Yes | Duration within which the key is pressed. |
| isIntercepted | Number | Yes| Whether the key can be intercepted.| | isIntercepted | boolean | Yes | Whether the key can be intercepted.|
# Input Monitor # Input Monitor
The input monitor module implements listening for global touch events.
> **NOTE**<br> > **NOTE**<br>
> - 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 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.
...@@ -10,7 +11,7 @@ ...@@ -10,7 +11,7 @@
## Modules to Import ## Modules to Import
``` ```js
import inputMonitor from '@ohos.multimodalInput.inputMonitor'; import inputMonitor from '@ohos.multimodalInput.inputMonitor';
``` ```
...@@ -24,7 +25,9 @@ ohos.permission.INPUT_MONITORING ...@@ -24,7 +25,9 @@ ohos.permission.INPUT_MONITORING
on(type: "touch", receiver: TouchEventReceiver): void on(type: "touch", receiver: TouchEventReceiver): void
Starts listening for global input events. Starts listening for global touch events.
This is a system API.
**Required permissions**: ohos.permission.INPUT_MONITORING **Required permissions**: ohos.permission.INPUT_MONITORING
...@@ -32,32 +35,17 @@ Starts listening for global input events. ...@@ -32,32 +35,17 @@ Starts listening for global input events.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | -------------------- | | -------- | ----------------------------------------- | ---- | ------------------------------- |
| type | string | Yes | Type of the input event. Currently, only **touch** events are supported.| | type | string | Yes | Type of the input event to listen for. The value is **touch**.|
| receiver | [TouchEventReceiver](#toucheventreceiver) | Yes | Callback used to return the touch event. | | receiver | [TouchEventReceiver](#toucheventreceiver) | Yes | Callback used to return the touch event. |
**Example** **Example**
``` ```js
export default { inputMonitor.off("touch", (event) => {
callback: function (value) { // A touch event is consumed.
if (checkEvent(value)) { return false;
// The event meets the service requirement and is consumed. });
return true;
} else {
// The event does not meet the service requirement and is not consumed.
return false;
}
},
testOn: function () {
console.info("InputMonitorJsTest---start---testOn");
inputMonitor.on(
"touch",
this.callback
);
console.info("InputMonitorJsTest---end---testOn");
}
}
``` ```
...@@ -65,7 +53,9 @@ export default { ...@@ -65,7 +53,9 @@ export default {
off(type: "touch", receiver?: TouchEventReceiver): void off(type: "touch", receiver?: TouchEventReceiver): void
Stops listening for global input events. Stops listening for global touch events.
This is a system API.
**Required permissions**: ohos.permission.INPUT_MONITORING **Required permissions**: ohos.permission.INPUT_MONITORING
...@@ -73,43 +63,22 @@ Stops listening for global input events. ...@@ -73,43 +63,22 @@ Stops listening for global input events.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | -------------------- | | -------- | ----------------------------------------- | ---- | ------------------------------- |
| type | string | Yes | Type of the input event. Currently, only **touch** events are supported.| | type | string | Yes | Type of the input event to listen for. The value is **touch**.|
| receiver | [TouchEventReceiver](#toucheventreceiver) | No | Callback used to return the touch event. | | receiver | [TouchEventReceiver](#toucheventreceiver) | No | Callback used to return the touch event. |
**Example** **Example**
``` ```js
export default { inputMonitor.off("touch");
callback: function (value) {
if (checkEvent(value)) {
// The event meets the service requirement and is consumed.
return true;
} else {
// The event does not meet the service requirement and is not consumed.
return false;
}
},
testOff: function () {
console.info("InputMonitorJsTest---start---testOff");
inputMonitor.off(
"touch",
this.callback
);
console.info("InputMonitorJsTest---end---testOff");
}
}
``` ```
## TouchEventReceiver ## TouchEventReceiver
Represents the class of the callback used to return the touch event. The value **true** indicates that the touch event has been consumed, and the value **false** indicates the opposite. Represents the class of the callback used to return the touch event. If the value **true** is returned, the touch event has been consumed, and the event monitor will be closed.
### (touchEvent: TouchEvent): Boolean This is a system API.
Represents the callback used to return the touch event. You need to define the name of the callback function in the correct format. Ensure that the input parameter is of the **TouchEvent** type, and the return value is of the **Boolean** type.
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor **System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
...@@ -125,24 +94,10 @@ Represents the callback used to return the touch event. You need to define the n ...@@ -125,24 +94,10 @@ Represents the callback used to return the touch event. You need to define the n
**Example** **Example**
``` ```js
export default { inputMonitor.on("touch", (event) => {
callback: function (value) { // Implementation of the (touchEvent:TouchEvent): Boolean API. // A touch event is consumed.
if (checkEvent(value)) { return false;
// The event meets the service requirement and is consumed. });
return true; inputMonitor.off("touch");
} else {
// The event does not meet the service requirement and is not consumed.
return false;
}
},
testOff: function () {
console.info("InputMonitorJsTest---start---testOff");
inputMonitor.off(
"touch",
this.callback
);
console.info("InputMonitorJsTest---end---testOff");
}
}
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册