提交 db923db1 编写于 作者: S shawn_he

update doc

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 06debeac
......@@ -18,7 +18,7 @@ Enumerates trace flag types.
**System capability**: SystemCapability.HiviewDFX.HiTrace
| Name | Default Value | Description |
| Name | Value | Description |
| -------- | -------- | -------- |
| DEFAULT | 0 | Default flag. |
| INCLUDE_ASYNC | 1 | Asynchronous call flag. By default, only synchronous calls are traced. If this flag is set, both synchronous and asynchronous calls will be traced. |
......@@ -35,7 +35,7 @@ Enumerates trace point types.
**System capability**: SystemCapability.HiviewDFX.HiTrace
| Name| Default Value | Description |
| Name| Value | Description |
| -------- | -------- | -------- |
| CS | 0 | Client Send (CS) trace point. |
| CR | 1 | Client Receive (CS) trace point. |
......@@ -49,7 +49,7 @@ Enumerates communication modes.
**System capability**: SystemCapability.HiviewDFX.HiTrace
| Name| Default Value | Description |
| Name| Value | Description |
| -------- | -------- | -------- |
| DEFAULT | 0 | Default communication mode. |
| THREAD | 1 | Inter-thread communication. |
......@@ -84,7 +84,7 @@ Starts call chain tracing. This API works in synchronous manner.
| name | string | Yes| Traced service name. |
| flags | number | No| Trace flag combination. For details, see [HiTraceFlag](#hitraceflag). |
**Return Value**
**Return value**
| Type | Description |
| -------- | -------- |
......@@ -126,7 +126,7 @@ Obtains the trace ID. This API works in synchronous manner.
**System capability**: SystemCapability.HiviewDFX.HiTrace
**Return Value**
**Return value**
| Type | Description |
| -------- | -------- |
......@@ -187,7 +187,7 @@ Creates a trace span. This API works in synchronous manner.
**System capability**: SystemCapability.HiviewDFX.HiTrace
**Return Value**
**Return value**
| Type | Description |
| -------- | -------- |
......@@ -240,7 +240,7 @@ Checks whether a **HiTraceId** instance is valid. This API works in synchronous
| -------- | -------- | -------- | -------- |
| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance. |
**Return Value**
**Return value**
| Type | Description |
| -------- | -------- |
......@@ -268,7 +268,7 @@ Checks whether the specified trace flag in the **HiTraceId** instance is enabled
| id | [HiTraceId](#hitraceid) | Yes | **HiTraceId** instance. |
| flag | [HiTraceFlag](#hitraceflag) | Yes | Specified trace flag. |
**Return Value**
**Return value**
| Type | Description |
| -------- | -------- |
......
# Input Consumer
The Input Consumer module implements listening for key events.
The Input Consumer 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 of this module are system APIs and cannot be called by third-party applications.
> - The APIs provided by this module are system APIs.
## Modules to Import
```
```js
import inputConsumer from '@ohos.multimodalInput.inputConsumer';
```
......@@ -21,32 +21,29 @@ import inputConsumer from '@ohos.multimodalInput.inputConsumer';
on(type: "key", keyOptions: KeyOptions, callback: Callback&lt;KeyOptions&gt;): void
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**.
This is a system API.
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.
**System capability**: SystemCapability.MultimodalInput.Input.InputConsumer
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the key input event to listen for. Only **key** is supported.|
| 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.<br> When a key input event that meets the specified options occurs, **keyOptions** will be passed as an input parameter to **callback**.|
| Name | Type | Mandatory | Description |
| ---------- | -------------------------- | ---- | ---------------------------------------- |
| type | string | Yes | Event type. Currently, only **key** is supported. |
| keyOptions | [KeyOptions](#keyoptions) | Yes | Combination key options. |
| callback | Callback&lt;KeyOptions&gt; | Yes | Callback used to return the combination key data when a combination key event that meets the specified condition occurs.|
**Example**
```
let keyOptions = { preKeys: [], finalKey: 18, isFinalKeyDown: true, finalKeyDownDuration: 0 }
let callback = function (keyOptions) {
console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey,
"isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration)
}
```js
let leftAltKey = 2045;
let tabKey = 2049;
try {
inputConsumer.on(inputConsumer.SubscribeType.KEY, keyOptions, callback);
inputConsumer.on("key", {preKeys: [leftAltKey], finalKey: tabKey, isFinalKeyDown: true, finalKeyDownDuration: 0}, keyOptions => {
console.log(`keyOptions: ${JSON.stringify(keyOptions)}`);
});
} catch (error) {
console.info(`inputConsumer.on, error.code=${JSON.stringify(error.code)}, error.msg=${JSON.stringify(error.message)}`);
console.log(`Subscribe failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
......@@ -55,49 +52,63 @@ try {
off(type: "key", keyOptions: KeyOptions, callback?: Callback&lt;KeyOptions&gt;): void
Stops listening for combination key events.
This is a system API.
Disables listening for combination key events.
**System capability**: SystemCapability.MultimodalInput.Input.InputConsumer
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the key input event to listen for. Only **key** is supported.|
| 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 **keyOptions** when listening starts.|
| Name | Type | Mandatory | Description |
| ---------- | -------------------------- | ---- | ------------------------------- |
| 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.|
**Example**
```js
let leftAltKey = 2045;
let tabKey = 2049;
// Disable listening for a single callback function.
let callback = function (keyOptions) {
console.log(`keyOptions: ${JSON.stringify(keyOptions)}`);
}
let keyOption = {preKeys: [leftAltKey], finalKey: tabKey, isFinalKeyDown: true, finalKeyDownDuration: 0};
try {
inputConsumer.on("key", keyOption, callback);
inputConsumer.off("key", keyOption, callback);
console.log(`Unsubscribe success`);
} catch (error) {
console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
let keyOptions = { preKeys: [], finalKey: 18, isFinalKeyDown: true, finalKeyDownDuration: 0 }
```js
let leftAltKey = 2045;
let tabKey = 2049;
// Disable listening for all callback functions.
let callback = function (keyOptions) {
console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey,
"isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration)
console.log(`keyOptions: ${JSON.stringify(keyOptions)}`);
}
let keyOption = {preKeys: [leftAltKey], finalKey: tabKey, isFinalKeyDown: true, finalKeyDownDuration: 0};
try {
inputConsumer.off(inputConsumer.SubscribeType.KEY, keyOptions, callback);
inputConsumer.on("key", keyOption, callback);
inputConsumer.off("key", keyOption);
console.log(`Unsubscribe success`);
} catch (error) {
console.info(`inputConsumer.off, error.code=${JSON.stringify(error.code)}, error.msg=${JSON.stringify(error.message)}`);
console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## keyOptions
## KeyOptions
Defines the key options that are met when a combination key input event occurs.
This is a system API.
Represents combination key options.
**System capability**: SystemCapability.MultimodalInput.Input.InputConsumer
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| preKeys | Array | Yes| Array of precedent keys. This parameter can be left empty. There is no requirement on the sequence of precedent keys.|
| finalKey | Number | Yes| Final key in the combination key. This parameter cannot be left blank.|
| isFinalKeyDown | boolean | Yes| Whether the final key is pressed or released. By default, the final key is pressed.|
| finalKeyDownDuration | Number | Yes| Duration for pressing the final key. By default, there is no requirement on the duration.|
| 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. |
......@@ -2,11 +2,11 @@
The Key Injection module implements injection of key events.
> **NOTE**<br>
> **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 of this module are system APIs and cannot be called by third-party applications.
> - The APIs provided by this module are system APIs.
## Modules to Import
......@@ -21,9 +21,7 @@ import inputEventClient from '@ohos.multimodalInput.inputEventClient';
injectEvent({KeyEvent: KeyEvent}): void
Injects a key event.
This is a system API.
Injects a key event. Currently, key injection is supported only for the **Back** key (key value 2).
**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator
......@@ -37,37 +35,36 @@ This is a system API.
```js
try {
var keyEvent = {
let backKeyDown = {
isPressed: true,
keyCode: 2,
keyDownDuration: 0,
isIntercepted: false
}
inputEventClient.injectKeyEvent({ KeyEvent: keyEvent });
var keyEvent1 = {
inputEventClient.injectEvent({ KeyEvent: backKeyDown });
let backKeyUp = {
isPressed: false,
keyCode: 2,
keyDownDuration: 0,
isIntercepted: false
};
inputEventClient.injectKeyEvent({ KeyEvent: keyEvent1 });
inputEventClient.injectEvent({ KeyEvent: backKeyUp });
} catch (error) {
console.info("injectKeyEvent " + error.code + " " + error.message);
console.log(`Failed to inject KeyEvent, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## KeyEvent
Defines the information about the key event to inject.
Represents information about the key event to inject.
**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator
**Parameters**
| Name | Type | Mandatory | Description |
| --------------- | ------- | ---- | --------- |
| isPressed | boolean | Yes | Whether the key is pressed. |
| keyCode | number | Yes | Key code. |
| keyDownDuration | number | Yes | Duration within which the key is pressed. |
| isIntercepted | boolean | Yes | Whether the key can be intercepted.|
| 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. |
# Input Monitor
The Input Monitor module implements listening for global touch events.
The Input Monitor module implements listening for events of input devices (namely, touchscreen and mouse).
> **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.
> **NOTE**
>
> - The APIs of this module are system APIs and cannot be called by third-party applications.
> - 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.
## Modules to Import
......@@ -16,80 +17,73 @@ import inputMonitor from '@ohos.multimodalInput.inputMonitor';
```
## Required Permissions
ohos.permission.INPUT_MONITORING
## inputMonitor.on
on(type: "touch", receiver: TouchEventReceiver): void
Enables listening for global touch events.
This is a system API.
**Required permissions**: ohos.permission.INPUT_MONITORING
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------- | ---- | ------------------------------- |
| 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. |
| 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.|
**Example**
**Example**
```js
try {
inputMonitor.on("touch", (data)=> {
console.info(`monitorOnTouchEvent success ${JSON.stringify(data)}`);
return false;
});
inputMonitor.on("touch", (touchEvent) => {
console.log(`Monitor on success ${JSON.stringify(touchEvent)}`);
return false;
});
} catch (error) {
console.info("onMonitor " + error.code + " " + error.message)
console.log(`Monitor on failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputMonitor.on<sup>9+</sup>
on(type: "mouse", receiver: Callback&lt;MouseEvent&gt;): void
Enables listening for global mouse events.
This is a system API.
**Required permissions**: ohos.permission.INPUT_MONITORING
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------------- |
| type | string | Yes | Type of the input event to listen for. The value is **mouse**.|
| receiver | Callback&lt;MouseEvent&gt; | Yes | Callback used to return the mouse event. |
| 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. |
**Example**
```js
try {
inputMonitor.on("mouse", (data)=> {
console.info(`monitorOnMouseEvent success ${JSON.stringify(data)}`);
return false;
});
inputMonitor.on("mouse", (mouseEvent) => {
console.log(`Monitor on success ${JSON.stringify(mouseEvent)}`);
return false;
});
} catch (error) {
console.info("onMonitor " + error.code + " " + error.message)
console.log(`Monitor on failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputMonitor.off
off(type: "touch", receiver?: TouchEventReceiver): void
Stops listening for global touch events.
This is a system API.
Disables listening for global touch events.
**Required permissions**: ohos.permission.INPUT_MONITORING
......@@ -97,41 +91,48 @@ This is a system API.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------- | ---- | ------------------------------- |
| 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. |
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ------------------- |
| type | string | Yes | Type of the input device event. The value is **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**
**Example**
```js
// Disable listening globally.
// Disable listening for a single callback function.
function callback(touchEvent) {
console.log(`Monitor on success ${JSON.stringify(touchEvent)}`);
return false;
};
try {
inputMonitor.off("touch");
inputMonitor.on("touch", callback);
inputMonitor.off("touch", callback);
console.log(`Monitor off success`);
} catch (error) {
console.info("offMonitor " + error.code + " " + error.message)
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
// Disable listening for this receiver.
callback:function(data) {
console.info(`call success ${JSON.stringify(data)}`);
},
try {
inputMonitor.on("touch", this.callback);
} catch (error) {
console.info("onTouchMonitor " + error.code + " " + error.message)
},
```
```js
// Cancel listening for all callback functions.
function callback(touchEvent) {
console.log(`Monitor on success ${JSON.stringify(touchEvent)}`);
return false;
};
try {
inputMonitor.off("touch",this.callback);
inputMonitor.on("touch", callback);
inputMonitor.off("touch");
console.log(`Monitor off success`);
} catch (error) {
console.info("offTouchMonitor " + error.code + " " + error.message)
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
off(type: "mouse", receiver?:Callback\<MouseEvent>):void
## inputMonitor.off<sup>9+</sup>
Stops listening for global mouse events.
off(type: "mouse", receiver?: Callback&lt;MouseEvent&gt;): void
This is a system API.
Stops listening for global mouse events.
**Required permissions**: ohos.permission.INPUT_MONITORING
......@@ -139,43 +140,48 @@ This is a system API.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------------- |
| type | string | Yes | Type of the input event to listen for. The value is **mouse**.|
| receiver | Callback&lt;MouseEvent&gt; | No | Callback used to return the mouse event. |
| Name | Type | Mandatory | Description |
| -------- | -------------------------- | ---- | ------------------- |
| type | string | Yes | Type of the input device event. The value is **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**
```js
// Disable listening globally.
// Disable listening for a single callback.
function callback(mouseEvent) {
console.log(`Monitor on success ${JSON.stringify(mouseEvent)}`);
return false;
};
try {
inputMonitor.off("mouse");
inputMonitor.on("mouse", callback);
inputMonitor.off("mouse", callback);
console.log(`Monitor off success`);
} catch (error) {
console.info("offMonitor " + error.code + " " + error.message)
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
// Disable listening for this receiver.
callback:function(data) {
console.info(`call success ${JSON.stringify(data)}`);
},
try {
inputMonitor.on("mouse", this.callback);
} catch (error) {
console.info("onMouseMonitor " + error.code + " " + error.message)
},
```
```js
// Disable listening for all callback functions.
function callback(mouseEvent) {
console.log(`Monitor on success ${JSON.stringify(mouseEvent)}`);
return false;
};
try {
inputMonitor.off("mouse", this.callback);
inputMonitor.on("mouse", callback);
inputMonitor.off("mouse");
console.log(`Monitor off success`);
} catch (error) {
console.info("offMouseMonitor " + error.code + " " + error.message)
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## TouchEventReceiver
Provides the callback of touch events.
Represents the callback used to return the touch event.
This is a system API.
**Required permissions**: ohos.permission.INPUT_MONITORING
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
......@@ -183,24 +189,26 @@ This is a system API.
| Name | Type | Mandatory | Description |
| ---------- | ---------------------------------------- | ---- | ---------------------------------------- |
| touchEvent | [TouchEvent](../arkui-js/js-components-common-events.md) | Yes | Callback used to return the touch event.|
| touchEvent | [TouchEvent](../arkui-js/js-components-common-events.md) | Yes | Touch event.|
**Return value**
| Type | Description |
| ------- | -------------------------------------- |
| Boolean | Result indicating whether the touch event has been consumed by the input monitor. The value **true** indicates that the touch event has been consumed, and the value **false** indicates the opposite.|
| Type | Description |
| ------- | ---------------------------------------- |
| Boolean | Result indicating whether the touch event will be dispatched to the window. The value **true** indicates that the touch event will be dispatched to the window, and the value **false** indicates the opposite.|
**Example**
**Example**
```js
try {
inputMonitor.on("touch", (event) => {
// If true is returned, all subsequent events of this operation will be consumed by the listener, instead of being distributed to the window.
return false;
inputMonitor.on("touch", touchEvent => {
if (touchEvent.touches.length == 3) {// Three fingers are pressed.
return true;
} else {
return false;
}
});
inputMonitor.off("touch");
} catch (error) {
console.info("offMonitor " + error.code + " " + error.message)
console.log(`Monitor on failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
# Key Event
The Key Event module provides key events reported by an input device.
Represents key 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
```js
import {Action,Key,KeyEvent} from '@ohos.multimodalInput.keyEvent';
import {Action, Key, KeyEvent} from '@ohos.multimodalInput.keyEvent';
```
## Action
**System capability**: SystemCapability.MultimodalInput.Input.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| CANCEL | number | Yes| No| Cancellation of a key action.|
| DOWN | number | Yes| No| Pressing of a key.|
| UP | number | Yes| No| Release of a key.|
| Name | Value | Description |
| ------ | ------- | -------- |
| CANCEL | 0 | Cancellation of a key action.|
| DOWN | 1 | Pressing of a key.|
| UP | 2 | Release of a key.|
## Key
**System capability**: SystemCapability.MultimodalInput.Input.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| code | KeyCode | Yes| No| Keycode.|
| pressedTime | number | Yes| No| Time when the key is pressed.|
| deviceId | number | Yes| No| Device to which the key belongs.|
| Name | Type| Readable| Writable| Description |
| ----------- | -------- | ---- | ---- | -------------- |
| code | KeyCode | Yes | No | Keycode. |
| pressedTime | number | Yes | No | Time when the key is pressed.|
| deviceId | number | Yes | No | ID of the device to which the key belongs. |
## KeyEvent
**System capability**: SystemCapability.MultimodalInput.Input.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| action | Action | Yes| No| Key action.|
| key | Key | Yes| No| Key that has changed.|
| 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.|
| 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.|
| numLock | boolean | Yes| No| Whether numLock is active.|
| scrollLock | boolean | Yes| No| Whether scrollLock is active.|
| Name | Type| Readable| Writable| Description |
| ----------- | -------- | ---- | ---- | ------------------------------ |
| action | Action | Yes | No | Key action. |
| 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. |
| 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. |
| numLock | boolean | Yes | No | Whether numLock is active. |
| scrollLock | boolean | Yes | No | Whether scrollLock is active.|
......@@ -2,7 +2,7 @@
Represents 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
......@@ -15,75 +15,75 @@ import {Action,Button,Axis,AxisValue,MouseEvent} from '@ohos.multimodalInput.mou
**System capability**: SystemCapability.MultimodalInput.Input.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| CANCEL | number | Yes| No| Cancellation of a mouse action.|
| MOVE | number | Yes| No| Moving of the mouse pointer.|
| BUTTON_DOWN | number | Yes| No| Pressing of a mouse button.|
| BUTTON_UP | number | Yes| No| Release of a mouse button.|
| AXIS_BEGIN | number | Yes| No| Beginning of the axis event associated with the mouse.|
| AXIS_UPDATE | number | Yes| No| Updating of the axis event associated with the mouse.|
| AXIS_END | number | Yes| No| Ending of the axis event associated with the mouse.|
| Name | Value| Description |
| ----------- | -------- | -------------------- |
| CANCEL | 0 | Cancellation of a mouse action. |
| MOVE | 1 | Moving of the mouse pointer. |
| BUTTON_DOWN | 2 | Pressing of a mouse button. |
| BUTTON_UP | 3 | Release of a mouse button. |
| AXIS_BEGIN | 4 | Beginning of the axis event associated with the mouse.|
| 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
**System capability**: SystemCapability.MultimodalInput.Input.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| LEFT | number | Yes| No| Left button on the mouse.|
| MIDDLE | number | Yes| No| Middle button on the mouse.|
| RIGHT | number | Yes| No| Right button on the mouse.|
| SIDE | number | Yes| No| Side button on the mouse.|
| EXTRA | number | Yes| No| Extended button on the mouse.|
| FORWARD | number | Yes| No| Forward button on the mouse.|
| BACK | number | Yes| No| Back button on the mouse.|
| TASK | number | Yes| No| Task button on the mouse.|
| Name | Value | Description |
| ------- | ------| ----- |
| LEFT | 0 | Left button on the mouse. |
| MIDDLE | 1 | Middle button on the mouse. |
| RIGHT | 2 | Right button on the mouse. |
| SIDE | 3 | Side button on the mouse.|
| EXTRA | 4 | Extended button on the mouse.|
| FORWARD | 5 | Forward button on the mouse.|
| BACK | 6 | Back button on the mouse.|
| TASK | 7 | Task button on the mouse.|
## Axis
**System capability**: SystemCapability.MultimodalInput.Input.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| SCROLL_VERTICAL | number | Yes| No| Vertical scroll axis.|
| SCROLL_HORIZONTAL | number | Yes| No| Horizontal scroll axis.|
| PINCH | number | Yes| No| Pinch axis.|
| Name | Value | Description |
| ----------------- | ------- | ----- |
| SCROLL_VERTICAL | 0 | Vertical scroll axis.|
| SCROLL_HORIZONTAL | 1 | Horizontal scroll axis.|
| PINCH | 2 | Pinch axis. |
## AxisValue
**System capability**: SystemCapability.MultimodalInput.Input.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| axis | Axis | Yes| No| Axis type.|
| value | number | Yes| No| Axis value.|
| Name | Type | Readable | Writable | Description |
| ----- | ------ | ---- | ---- | ---- |
| axis | Axis | Yes | No | Axis type. |
| value | number | Yes | No | Axis value. |
## MouseEvent
**System capability**: SystemCapability.MultimodalInput.Input.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| action | Action | Yes| No| Mouse event action.|
| screenX | number | Yes| No| X coordinate of the mouse pointer on the screen.|
| screenY | number | Yes| No| Y coordinate of the mouse pointer on the screen.|
| windowX | number | Yes| No| X coordinate of the mouse pointer in the window.|
| windowY | number | Yes| No| Y coordinate of the mouse pointer in the window.|
| rawDeltaX | number | Yes| No| X axis offset relative to the previous reported mouse pointer position. When the mouse pointer is at the edge of the screen, the value may be less than the difference of the X coordinate reported twice.|
| rawDeltaY | number | Yes| No| Y axis offset relative to the previous reported mouse pointer position.|
| button | Button | Yes| No| Button that is currently pressed or released.|
| pressedButtons | Button[] | Yes| No| Button that is 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.|
| 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.|
| numLock | boolean | Yes| No| Whether numLock is active.|
| scrollLock | boolean | Yes| No| Whether scrollLock is active.|
| Name | Type | Readable | Writable | Description |
| -------------- | ----------- | ---- | ---- | ---------------------------------------- |
| 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
| 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. |
| 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. |
| numLock | boolean | Yes | No | Whether numLock is active. |
| scrollLock | boolean | Yes | No | Whether scrollLock is active. |
......@@ -18,8 +18,6 @@ getDefaultCellularDataSlotId(callback: AsyncCallback\<number\>): void
Obtains the default slot of the SIM card used for mobile data. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Telephony.CellularData
**Parameters**
......@@ -42,8 +40,6 @@ getDefaultCellularDataSlotId(): Promise\<number\>
Obtains the default slot of the SIM card used for mobile data. This API uses a promise to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Telephony.CellularData
**Return value**
......@@ -63,14 +59,12 @@ promise.then((data) => {
});
```
## data.getDefaultCellularDataSlotIdSync
## data.getDefaultCellularDataSlotIdSync<sup>9+</sup>
getDefaultCellularDataSlotIdSync(): number
Obtains the default SIM card used for mobile data synchronously.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Telephony.CellularData
**Return value**
......@@ -85,7 +79,6 @@ Obtains the default SIM card used for mobile data synchronously.
console.log("Result: "+ data.getDefaultCellularDataSlotIdSync())
```
## data.setDefaultCellularDataSlotId
setDefaultCellularDataSlotId(slotId: number, callback: AsyncCallback\<void\>): void
......@@ -102,8 +95,8 @@ This is a system API.
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: clearing the default configuration|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. |
| slotId | number | Yes | SIM card slot ID. <br>**0**: card slot 1<br>**1**: card slot 2<br>**-1**: Clears the default configuration.|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. |
**Example**
......@@ -129,13 +122,13 @@ This is a system API.
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: clearing the default configuration|
| slotId | number | Yes | SIM card slot ID. <br>**0**: card slot 1<br>**1**: card slot 2<br>**-1**: Clears the default configuration.|
**Return value**
| Type | Description |
| -------------- | ------------------------------- |
| Promise<\void\> | Promise used to return the result. |
| Type | Description |
| --------------- | ------------------------------- |
| Promise\<void\> | Promise used to return the result.|
**Example**
......@@ -199,7 +192,7 @@ promise.then((data) => {
getCellularDataState(callback: AsyncCallback\<DataConnectState\>): void
Obtains the connection status of the PS domain. This API uses an asynchronous callback to return the result.
Obtains the connection status of the packet switched (PS) domain. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Telephony.CellularData
......@@ -256,7 +249,7 @@ Checks whether the cellular data service is enabled. This API uses an asynchrono
| Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.<br>- **true**: The cellular data service is enabled.<br>- **false**: The cellular data service is disabled.|
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.<br>**true**: The cellular data service is enabled.<br>**false**: The cellular data service is disabled.|
**Example**
......@@ -280,7 +273,7 @@ Checks whether the cellular data service is enabled. This API uses a promise to
| Type | Description |
| ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.<br>- **true**: The cellular data service is enabled.<br>- **false**: The cellular data service is disabled.|
| Promise\<boolean\> | Promise used to return the result.<br>**true**: The cellular data service is enabled.<br>**false**: The cellular data service is disabled.|
**Example**
......@@ -297,7 +290,7 @@ promise.then((data) => {
isCellularDataRoamingEnabled(slotId: number, callback: AsyncCallback\<boolean\>): void
Checks whether the cellular data roaming service is enabled. This API uses an asynchronous callback to return the result.
Checks whether roaming is enabled for the cellular data service. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
......@@ -308,7 +301,7 @@ Checks whether the cellular data roaming service is enabled. This API uses an as
| Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2 |
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.<br>- **true**: The cellular data roaming service is enabled. <br>- **false**: The cellular data roaming service is disabled. |
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.<br>**true**: Roaming is enabled for the cellular data service.<br>**false**: Roaming is disabled for the cellular data service.|
**Example**
......@@ -322,7 +315,7 @@ data.isCellularDataRoamingEnabled(0, (err, data) => {
isCellularDataRoamingEnabled(slotId: number): Promise\<boolean\>
Checks whether the cellular data roaming service is enabled. This API uses a promise to return the result.
Checks whether roaming is enabled for the cellular data service. This API uses a promise to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
......@@ -338,7 +331,7 @@ Checks whether the cellular data roaming service is enabled. This API uses a pro
| Type | Description |
| ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.<br>- **true**: The cellular data roaming service is enabled.<br>- **false**: The cellular data roaming service is disabled.|
| Promise\<boolean\> | Promise used to return the result.<br>**true**: Roaming is enabled for the cellular data service.<br>**false**: Roaming is disabled for the cellular data service.|
**Example**
......@@ -585,7 +578,6 @@ promise.then((data) => {
});
```
## DataFlowType
Defines the cellular data flow type.
......@@ -602,14 +594,14 @@ Defines the cellular data flow type.
## DataConnectState
Describes the connection status of a cellular data connection.
Describes the connection status of a cellular data link.
**System capability**: SystemCapability.Telephony.CellularData
| Name | Value | Description |
| ----------------------- | ---- | -------------------------- |
| DATA_STATE_UNKNOWN | -1 | The status of the cellular data connection is unknown. |
| DATA_STATE_DISCONNECTED | 0 | The cellular data connection is disconnected. |
| DATA_STATE_CONNECTING | 1 | The cellular data connection is being established.|
| DATA_STATE_CONNECTED | 2 | The cellular data connection is established. |
| DATA_STATE_SUSPENDED | 3 | The cellular data connection is suspended. |
| DATA_STATE_UNKNOWN | -1 | The status of the cellular data link is unknown. |
| DATA_STATE_DISCONNECTED | 0 | The cellular data link is disconnected. |
| DATA_STATE_CONNECTING | 1 | The cellular data link is being connected.|
| DATA_STATE_CONNECTED | 2 | The cellular data link is connected. |
| DATA_STATE_SUSPENDED | 3 | The cellular data link is suspended. |
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册