has.onKeyboardHeightChange(function callback)
Enables listening for keyboard height change events.
Since: 1.0.4
Parameters
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| callback | function | Yes | Callback for the keyboard height change event. |
Return value of callback
| Parameter | Type | Description |
|---|---|---|
| height | number | Keyboard height. |
Example:
has.onKeyboardHeightChange((res) => {
console.info('keyboard height is: ', res.height);
}); has.offKeyboardHeightChange(function callback)
Listener function for removing the keyboard height change event.
Since: 1.0.21
Parameters
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| callback | function | No | Listener function passed by has.onKeyboardHeightChange. If this parameter is not passed, all listener functions are removed. |
Example:
const keyboardHeightChangeFn = function(res) {
console.info('keyboard height is: ', res.height);
};
has.onKeyboardHeightChange(keyboardHeightChangeFn);
has.offKeyboardHeightChange(keyboardHeightChangeFn);
has.offKeyboardHeightChange(); has.hideKeyboard(Object object)
Hides a keyboard after the keyboard is shown by using input or textarea of focus.
Since: 1.0.4
Parameters
The input parameter is an object containing the following fields.
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| success | function | No | Callback triggered when the API call is successful. |
| fail | function | No | Callback triggered when the API call fails. |
| complete | function | No | Callback triggered when the API call is complete, regardless of success or failure. |
Error codes
| Error Code | Error Message |
|---|---|
| 12003501 | hideKeyboard error. |
Example:
has.hideKeyboard({
success: () => {
console.info('hideKeyboard success');
},
fail: (err) => {
console.error('hideKeyboard fail', err);
},
complete: (res) => {
console.info('hideKeyboard complete', res);
}
}); has.getSelectedTextRange(Object object)
Obtains the cursor position in the text box after input or textarea of focus is called.
This API is valid only when the focus is on.
Since: 1.0.4
Parameters
The input parameter is an object containing the following fields.
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| success | function | No | Callback triggered when the API call is successful. |
| fail | function | No | Callback triggered when the API call fails. |
| complete | function | No | Callback triggered when the API call is complete, regardless of success or failure. |
Return value of success
| Parameter | Type | Description |
|---|---|---|
| start | number | Start position of the cursor in the text box. |
| end | number | End position of the cursor in the text box. |
Error codes
| Error Code | Error Message |
|---|---|
| 12003601 | 1. getSelectedTextRange error, error is no focused. 2. getSelectedTextRange error. |
Example:
has.getSelectedTextRange({
success: (res) => {
console.info('getSelectedTextRange success', res);
},
fail: (err) => {
console.error('getSelectedTextRange fail', err);
},
complete: (res) => {
console.info('getSelectedTextRange complete', res);
}
});