提交 7bb6c2ed 编写于 作者: Z zhengjiangliang

doc文档示例代码整改

Signed-off-by: Nzhengjiangliang <zhengjiangliang@huawei.com>
Change-Id: Iaee7d59296d2f037bc50a9c010c74bf3696dbc23
上级 337066f7
...@@ -84,16 +84,17 @@ getDefaultDisplaySync(): Display ...@@ -84,16 +84,17 @@ getDefaultDisplaySync(): Display
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ----------------------- | | ------- | ----------------------- |
| 1400001 | This is invalid screen. | | 1400001 | Invalid display or screen. |
**示例:** **示例:**
```js ```js
let displayClass = null;
try { try {
let displayClass = display.getDefaultDisplaySync(); displayClass = display.getDefaultDisplaySync();
} catch (exception) { } catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}; }
``` ```
## display.getAllDisplays<sup>9+</sup> ## display.getAllDisplays<sup>9+</sup>
...@@ -116,7 +117,7 @@ getAllDisplays(callback: AsyncCallback&lt;Array&lt;Display&gt;&gt;): void ...@@ -116,7 +117,7 @@ getAllDisplays(callback: AsyncCallback&lt;Array&lt;Display&gt;&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ----------------------- | | ------- | ----------------------- |
| 1400001 | This is invalid screen. | | 1400001 | Invalid display or screen. |
**示例:** **示例:**
...@@ -152,7 +153,7 @@ getAllDisplays(): Promise&lt;Array&lt;Display&gt;&gt; ...@@ -152,7 +153,7 @@ getAllDisplays(): Promise&lt;Array&lt;Display&gt;&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ----------------------- | | ------- | ----------------------- |
| 1400001 | This is invalid screen. | | 1400001 | Invalid display or screen. |
**示例:** **示例:**
...@@ -195,7 +196,7 @@ hasPrivateWindow(displayId: number): boolean ...@@ -195,7 +196,7 @@ hasPrivateWindow(displayId: number): boolean
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1400003 | This window manager service work abnormally. | | 1400003 | This display manager service works abnormally. |
**示例:** **示例:**
...@@ -203,24 +204,24 @@ hasPrivateWindow(displayId: number): boolean ...@@ -203,24 +204,24 @@ hasPrivateWindow(displayId: number): boolean
let displayClass = null; let displayClass = null;
try { try {
displayClass = display.getDefaultDisplaySync(); displayClass = display.getDefaultDisplaySync();
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
return;
};
try { let ret = undefined;
let ret = display.hasPrivateWindow(displayClass.id); try {
} catch (exception) { ret = display.hasPrivateWindow(displayClass.id);
} catch (exception) {
console.error('Failed to check has privateWindow or not. Code: ' + JSON.stringify(exception)); console.error('Failed to check has privateWindow or not. Code: ' + JSON.stringify(exception));
}; }
if (ret == undefined) { if (ret == undefined) {
console.log("Failed to check has privateWindow or not."); console.log("Failed to check has privateWindow or not.");
} }
if (ret) { if (ret) {
console.log("There has privateWindow."); console.log("There has privateWindow.");
} else if (!ret) { } else if (!ret) {
console.log("There has no privateWindow."); console.log("There has no privateWindow.");
}; }
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}
``` ```
## display.on('add'|'remove'|'change') ## display.on('add'|'remove'|'change')
...@@ -243,12 +244,12 @@ on(type: 'add'|'remove'|'change', callback: Callback&lt;number&gt;): void ...@@ -243,12 +244,12 @@ on(type: 'add'|'remove'|'change', callback: Callback&lt;number&gt;): void
```js ```js
let callback = (data) => { let callback = (data) => {
console.info('Listening enabled. Data: ' + JSON.stringify(data)); console.info('Listening enabled. Data: ' + JSON.stringify(data));
} };
try { try {
display.on("add", callback); display.on("add", callback);
} catch (exception) { } catch (exception) {
console.error('Failed to register callback. Code: ' + JSON.stringify(exception)); console.error('Failed to register callback. Code: ' + JSON.stringify(exception));
}; }
``` ```
## display.off('add'|'remove'|'change') ## display.off('add'|'remove'|'change')
...@@ -273,7 +274,7 @@ try { ...@@ -273,7 +274,7 @@ try {
display.off("remove"); display.off("remove");
} catch (exception) { } catch (exception) {
console.error('Failed to unregister callback. Code: ' + JSON.stringify(exception)); console.error('Failed to unregister callback. Code: ' + JSON.stringify(exception));
}; }
``` ```
## display.getDefaultDisplay<sup>(deprecated)</sup> ## display.getDefaultDisplay<sup>(deprecated)</sup>
...@@ -412,7 +413,7 @@ promise.then((data) => { ...@@ -412,7 +413,7 @@ promise.then((data) => {
| alive | boolean | 是 | 否 | 显示设备是否启用。| | alive | boolean | 是 | 否 | 显示设备是否启用。|
| state | [DisplayState](#displaystate) | 是 | 否 | 显示设备的状态。| | state | [DisplayState](#displaystate) | 是 | 否 | 显示设备的状态。|
| refreshRate | number | 是 | 否 | 显示设备的刷新率。| | refreshRate | number | 是 | 否 | 显示设备的刷新率。|
| rotation | number | 是 | 否 | 显示设备的屏幕旋转角度。| | rotation | number | 是 | 否 | 显示设备的屏幕旋转角度。<br>值为0时,表示显示设备屏幕旋转为0°;<br>值为1时,表示显示设备屏幕旋转为90°;<br>值为2时,表示显示设备屏幕旋转为180°;<br>值为3时,表示显示设备屏幕旋转为270°。|
| width | number | 是 | 否 | 显示设备的宽度,单位为像素。| | width | number | 是 | 否 | 显示设备的宽度,单位为像素。|
| height | number | 是 | 否 | 显示设备的高度,单位为像素。| | height | number | 是 | 否 | 显示设备的高度,单位为像素。|
| densityDPI | number | 是 | 否 | 显示设备的屏幕密度,单位为DPI。| | densityDPI | number | 是 | 否 | 显示设备的屏幕密度,单位为DPI。|
...@@ -440,24 +441,25 @@ getCutoutInfo(callback: AsyncCallback&lt;CutoutInfo&gt;): void ...@@ -440,24 +441,25 @@ getCutoutInfo(callback: AsyncCallback&lt;CutoutInfo&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ----------------------- | | ------- | ----------------------- |
| 1400001 | This is invalid screen. | | 1400001 | Invalid display or screen. |
**示例:** **示例:**
```js ```js
let displayClass = null;
try { try {
let displayClass = display.getDefaultDisplaySync(); displayClass = display.getDefaultDisplaySync();
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
};
displayClass.getCutoutInfo((err, data) => { displayClass.getCutoutInfo((err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to get cutoutInfo. Code: ' + JSON.stringify(err)); console.error('Failed to get cutoutInfo. Code: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in getting cutoutInfo. data: ' + JSON.stringify(data)); console.info('Succeeded in getting cutoutInfo. data: ' + JSON.stringify(data));
}); });
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}
``` ```
### getCutoutInfo<sup>9+</sup> ### getCutoutInfo<sup>9+</sup>
getCutoutInfo(): Promise&lt;CutoutInfo&gt; getCutoutInfo(): Promise&lt;CutoutInfo&gt;
...@@ -478,19 +480,22 @@ getCutoutInfo(): Promise&lt;CutoutInfo&gt; ...@@ -478,19 +480,22 @@ getCutoutInfo(): Promise&lt;CutoutInfo&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ----------------------- | | ------- | ----------------------- |
| 1400001 | This is invalid screen. | | 1400001 | Invalid display or screen. |
**示例:** **示例:**
```js ```js
let displayClass = null;
try { try {
let displayClass = display.getDefaultDisplaySync(); displayClass = display.getDefaultDisplaySync();
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
};
let promise = displayClass.getCutoutInfo(); let promise = displayClass.getCutoutInfo();
promise.then((data) => { promise.then((data) => {
console.info('Succeeded in getting cutoutInfo. Data: ' + JSON.stringify(data)); console.info('Succeeded in getting cutoutInfo. Data: ' + JSON.stringify(data));
}); }).catch((err) => {
console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}
``` ```
...@@ -165,7 +165,7 @@ import window from '@ohos.window'; ...@@ -165,7 +165,7 @@ import window from '@ohos.window';
| --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | | --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
| type | [WindowType](#windowtype7) | 是 | 否 | 当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。 | | type | [WindowType](#windowtype7) | 是 | 否 | 当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。 |
| isEnable | boolean | 是 | 否 | 当前系统栏是否显示。true表示显示;false表示不显示。 | | isEnable | boolean | 是 | 否 | 当前系统栏是否显示。true表示显示;false表示不显示。 |
| region | [Rect](#rect) | 是 | 否 | 当前系统栏的位置及大小。 | | region | [Rect](#rect7) | 是 | 否 | 当前系统栏的位置及大小。 |
| backgroundColor | string | 是 | 否 | 系统栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00``#FF00FF00`。 | | backgroundColor | string | 是 | 否 | 系统栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00``#FF00FF00`。 |
| contentColor | string | 是 | 否 | 系统栏文字颜色。 | | contentColor | string | 是 | 否 | 系统栏文字颜色。 |
...@@ -204,10 +204,10 @@ import window from '@ohos.window'; ...@@ -204,10 +204,10 @@ import window from '@ohos.window';
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 参数类型 | 可读 | 可写 | 说明 |
| ---------- | ------------- | ---- | ---- | ------------------ | | ---------- | ------------- | ---- | ---- | ------------------ |
| visible<sup>9+</sup> | boolean | 是 | 是 | 规避区域是否可见。true表示可见;false表示不可见。 | | visible<sup>9+</sup> | boolean | 是 | 是 | 规避区域是否可见。true表示可见;false表示不可见。 |
| leftRect | [Rect](#rect) | 是 | 是 | 屏幕左侧的矩形区。 | | leftRect | [Rect](#rect7) | 是 | 是 | 屏幕左侧的矩形区。 |
| topRect | [Rect](#rect) | 是 | 是 | 屏幕顶部的矩形区。 | | topRect | [Rect](#rect7) | 是 | 是 | 屏幕顶部的矩形区。 |
| rightRect | [Rect](#rect) | 是 | 是 | 屏幕右侧的矩形区。 | | rightRect | [Rect](#rect7) | 是 | 是 | 屏幕右侧的矩形区。 |
| bottomRect | [Rect](#rect) | 是 | 是 | 屏幕底部的矩形区。 | | bottomRect | [Rect](#rect7) | 是 | 是 | 屏幕底部的矩形区。 |
## Size<sup>7+</sup> ## Size<sup>7+</sup>
...@@ -228,7 +228,7 @@ import window from '@ohos.window'; ...@@ -228,7 +228,7 @@ import window from '@ohos.window';
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 参数类型 | 可读 | 可写 | 说明 |
| ------------------------------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | | ------------------------------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
| windowRect<sup>7+</sup> | [Rect](#rect) | 是 | 是 | 窗口尺寸。 | | windowRect<sup>7+</sup> | [Rect](#rect7) | 是 | 是 | 窗口尺寸。 |
| type<sup>7+</sup> | [WindowType](#windowtype7) | 是 | 是 | 窗口类型。 | | type<sup>7+</sup> | [WindowType](#windowtype7) | 是 | 是 | 窗口类型。 |
| isFullScreen | boolean | 是 | 是 | 是否全屏,默认为false。true表示全屏;false表示非全屏。 | | isFullScreen | boolean | 是 | 是 | 是否全屏,默认为false。true表示全屏;false表示非全屏。 |
| isLayoutFullScreen<sup>7+</sup> | boolean | 是 | 是 | 窗口是否为沉浸式,默认为false。true表示沉浸式;false表示非沉浸式。 | | isLayoutFullScreen<sup>7+</sup> | boolean | 是 | 是 | 窗口是否为沉浸式,默认为false。true表示沉浸式;false表示非沉浸式。 |
...@@ -319,7 +319,7 @@ createWindow(config: Configuration, callback: AsyncCallback&lt;Window&gt;): void ...@@ -319,7 +319,7 @@ createWindow(config: Configuration, callback: AsyncCallback&lt;Window&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------- | | ------- | -------------------------------- |
| 1300001 | This is repeat operation. | | 1300001 | Repeated operation. |
| 1300006 | This window context is abnormal. | | 1300006 | This window context is abnormal. |
**示例:** **示例:**
...@@ -339,14 +339,14 @@ try { ...@@ -339,14 +339,14 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error('Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
``` ```
## window.createWindow<sup>9+</sup> ## window.createWindow<sup>9+</sup>
createWindow(config: Configuration): Promise&lt;Window&gt; createWindow(config: Configuration): Promise&lt;Window&gt;
创建子窗口,使用callback异步回调。 创建子窗口,使用Promise异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
...@@ -368,7 +368,7 @@ createWindow(config: Configuration): Promise&lt;Window&gt; ...@@ -368,7 +368,7 @@ createWindow(config: Configuration): Promise&lt;Window&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------- | | ------- | -------------------------------- |
| 1300001 | This is repeat operation. | | 1300001 | Repeated operation. |
| 1300006 | This window context is abnormal. | | 1300006 | This window context is abnormal. |
**示例:** **示例:**
...@@ -386,7 +386,7 @@ try { ...@@ -386,7 +386,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to create the window. Cause: ' + JSON.stringify(exception)); console.error('Failed to create the window. Cause: ' + JSON.stringify(exception));
}; }
``` ```
## window.findWindow<sup>9+</sup> ## window.findWindow<sup>9+</sup>
...@@ -412,11 +412,12 @@ findWindow(name: string): Window ...@@ -412,11 +412,12 @@ findWindow(name: string): Window
**示例:** **示例:**
```js ```js
let windowClass = null;
try { try {
let windowClass = window.findWindow('alertWindow'); windowClass = window.findWindow('alertWindow');
} catch (exception) { } catch (exception) {
console.error('Failed to find the Window. Cause: ' + JSON.stringify(exception)); console.error('Failed to find the Window. Cause: ' + JSON.stringify(exception));
}; }
``` ```
## window.getLastWindow<sup>9+</sup> ## window.getLastWindow<sup>9+</sup>
...@@ -458,7 +459,7 @@ try { ...@@ -458,7 +459,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
}; }
``` ```
## window.getLastWindow<sup>9+</sup> ## window.getLastWindow<sup>9+</sup>
...@@ -504,7 +505,7 @@ try { ...@@ -504,7 +505,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
}; }
``` ```
## window.minimizeAll<sup>9+</sup> ## window.minimizeAll<sup>9+</sup>
...@@ -529,22 +530,18 @@ minimizeAll(id: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -529,22 +530,18 @@ minimizeAll(id: number, callback: AsyncCallback&lt;void&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
```js ```js
import display from '@ohos.display' import display from '@ohos.display'
import window from '@ohos.window'
let displayClass = null;
try { try {
displayClass = display.getDefaultDisplaySync(); displayClass = display.getDefaultDisplaySync();
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
return;
};
try { try {
window.minimizeAll(displayClass.id, (err) => { window.minimizeAll(displayClass.id, (err) => {
if(err.code) { if(err.code) {
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err)); console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
...@@ -552,9 +549,12 @@ try { ...@@ -552,9 +549,12 @@ try {
} }
console.info('Succeeded in minimizing all windows.'); console.info('Succeeded in minimizing all windows.');
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception)); console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception));
}; }
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}
``` ```
## window.minimizeAll<sup>9+</sup> ## window.minimizeAll<sup>9+</sup>
...@@ -584,31 +584,30 @@ minimizeAll(id: number): Promise&lt;void&gt; ...@@ -584,31 +584,30 @@ minimizeAll(id: number): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
```js ```js
import display from '@ohos.display' import display from '@ohos.display'
import window from '@ohos.window'
let displayClass = null;
try { try {
displayClass = display.getDefaultDisplaySync(); displayClass = display.getDefaultDisplaySync();
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
return;
};
try { try {
let promise = window.minimizeAll(displayClass.id); let promise = window.minimizeAll(displayClass.id);
promise.then(()=> { promise.then(()=> {
console.info('Succeeded in minimizing all windows.'); console.info('Succeeded in minimizing all windows.');
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err)); console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception)); console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception));
}; }
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}
``` ```
## window.toggleShownStateForAllAppWindows<sup>9+</sup> ## window.toggleShownStateForAllAppWindows<sup>9+</sup>
...@@ -632,7 +631,7 @@ toggleShownStateForAllAppWindows(callback: AsyncCallback&lt;void&gt;): void ...@@ -632,7 +631,7 @@ toggleShownStateForAllAppWindows(callback: AsyncCallback&lt;void&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -643,7 +642,7 @@ window.toggleShownStateForAllAppWindows((err) => { ...@@ -643,7 +642,7 @@ window.toggleShownStateForAllAppWindows((err) => {
return; return;
} }
console.info('Succeeded in toggling shown state for all app windows.'); console.info('Succeeded in toggling shown state for all app windows.');
}) });
``` ```
## window.toggleShownStateForAllAppWindows<sup>9+</sup> ## window.toggleShownStateForAllAppWindows<sup>9+</sup>
...@@ -667,7 +666,7 @@ toggleShownStateForAllAppWindows(): Promise&lt;void&gt; ...@@ -667,7 +666,7 @@ toggleShownStateForAllAppWindows(): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -677,7 +676,7 @@ promise.then(()=> { ...@@ -677,7 +676,7 @@ promise.then(()=> {
console.info('Succeeded in toggling shown state for all app windows.'); console.info('Succeeded in toggling shown state for all app windows.');
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err)); console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err));
}) });
``` ```
## window.setWindowLayoutMode<sup>9+</sup> ## window.setWindowLayoutMode<sup>9+</sup>
...@@ -702,7 +701,7 @@ setWindowLayoutMode(mode: WindowLayoutMode, callback: AsyncCallback&lt;void&gt;) ...@@ -702,7 +701,7 @@ setWindowLayoutMode(mode: WindowLayoutMode, callback: AsyncCallback&lt;void&gt;)
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -717,7 +716,7 @@ try { ...@@ -717,7 +716,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception)); console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception));
}; }
``` ```
## window.setWindowLayoutMode<sup>9+</sup> ## window.setWindowLayoutMode<sup>9+</sup>
...@@ -747,7 +746,7 @@ setWindowLayoutMode(mode: WindowLayoutMode): Promise&lt;void&gt; ...@@ -747,7 +746,7 @@ setWindowLayoutMode(mode: WindowLayoutMode): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -761,7 +760,7 @@ try { ...@@ -761,7 +760,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception)); console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception));
}; }
``` ```
## window.on('systemBarTintChange')<sup>8+</sup> ## window.on('systemBarTintChange')<sup>8+</sup>
...@@ -777,9 +776,9 @@ on(type: 'systemBarTintChange', callback: Callback&lt;SystemBarTintState&gt;): v ...@@ -777,9 +776,9 @@ on(type: 'systemBarTintChange', callback: Callback&lt;SystemBarTintState&gt;): v
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 | | type | string | 是 | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 |
| callback | Callback&lt;[SystemBarTintState](#systembartintstate)&gt; | 是 | 回调函数。返回当前的状态栏、导航栏信息集合。 | | callback | Callback&lt;[SystemBarTintState](#systembartintstate8)&gt; | 是 | 回调函数。返回当前的状态栏、导航栏信息集合。 |
**示例:** **示例:**
...@@ -790,7 +789,7 @@ try { ...@@ -790,7 +789,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to enable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception)); console.error('Failed to enable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception));
}; }
``` ```
## window.off('systemBarTintChange')<sup>8+</sup> ## window.off('systemBarTintChange')<sup>8+</sup>
...@@ -806,9 +805,9 @@ off(type: 'systemBarTintChange', callback?: Callback&lt;SystemBarTintState &gt;) ...@@ -806,9 +805,9 @@ off(type: 'systemBarTintChange', callback?: Callback&lt;SystemBarTintState &gt;)
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 | | type | string | 是 | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 |
| callback | Callback&lt;[SystemBarTintState](#systembartintstate)&gt; | 否 | 回调函数。返回当前的状态栏、导航栏信息集合。 | | callback | Callback&lt;[SystemBarTintState](#systembartintstate8)&gt; | 否 | 回调函数。返回当前的状态栏、导航栏信息集合。 |
**示例:** **示例:**
...@@ -817,7 +816,7 @@ try { ...@@ -817,7 +816,7 @@ try {
window.off('systemBarTintChange'); window.off('systemBarTintChange');
} catch (exception) { } catch (exception) {
console.error('Failed to disable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception)); console.error('Failed to disable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception));
}; }
``` ```
## window.create<sup>(deprecated)</sup> ## window.create<sup>(deprecated)</sup>
...@@ -923,7 +922,7 @@ create(ctx: BaseContext, id: string, type: WindowType, callback: AsyncCallback&l ...@@ -923,7 +922,7 @@ create(ctx: BaseContext, id: string, type: WindowType, callback: AsyncCallback&l
```js ```js
let windowClass = null; let windowClass = null;
window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => { window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to create the window. Cause: ' + JSON.stringify(err)); console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
return; return;
...@@ -998,7 +997,7 @@ find(id: string, callback: AsyncCallback&lt;Window&gt;): void ...@@ -998,7 +997,7 @@ find(id: string, callback: AsyncCallback&lt;Window&gt;): void
```js ```js
let windowClass = null; let windowClass = null;
window.find('alertWindow', (err, data) => { window.find('alertWindow', (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
return; return;
...@@ -1109,7 +1108,7 @@ promise.then((data)=> { ...@@ -1109,7 +1108,7 @@ promise.then((data)=> {
console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
}) });
``` ```
## window.getTopWindow<sup>(deprecated)</sup> ## window.getTopWindow<sup>(deprecated)</sup>
...@@ -1179,7 +1178,7 @@ promise.then((data)=> { ...@@ -1179,7 +1178,7 @@ promise.then((data)=> {
console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
}) });
``` ```
## Window ## Window
...@@ -1220,8 +1219,8 @@ windowClass.hide((err) => { ...@@ -1220,8 +1219,8 @@ windowClass.hide((err) => {
console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in hiding the window. data: ' + JSON.stringify(data)); console.info('Succeeded in hiding the window.');
}) });
``` ```
### hide<sup>7+</sup> ### hide<sup>7+</sup>
...@@ -1256,7 +1255,7 @@ promise.then(()=> { ...@@ -1256,7 +1255,7 @@ promise.then(()=> {
console.info('Succeeded in hiding the window.'); console.info('Succeeded in hiding the window.');
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
}) });
``` ```
### hideWithAnimation<sup>9+</sup> ### hideWithAnimation<sup>9+</sup>
...@@ -1282,8 +1281,8 @@ hideWithAnimation(callback: AsyncCallback&lt;void&gt;): void ...@@ -1282,8 +1281,8 @@ hideWithAnimation(callback: AsyncCallback&lt;void&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
| 1300004 | This operation is not access. | | 1300004 | Unauthorized operation. |
**示例:** **示例:**
...@@ -1294,7 +1293,7 @@ windowClass.hideWithAnimation((err) => { ...@@ -1294,7 +1293,7 @@ windowClass.hideWithAnimation((err) => {
return; return;
} }
console.info('Succeeded in hiding the window with animation.'); console.info('Succeeded in hiding the window with animation.');
}) });
``` ```
### hideWithAnimation<sup>9+</sup> ### hideWithAnimation<sup>9+</sup>
...@@ -1320,18 +1319,18 @@ hideWithAnimation(): Promise&lt;void&gt; ...@@ -1320,18 +1319,18 @@ hideWithAnimation(): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
| 1300004 | This operation is not access. | | 1300004 | Unauthorized operation. |
**示例:** **示例:**
```js ```js
let promise = windowClass.hideWithAnimation(); let promise = windowClass.hideWithAnimation();
promise.then(()=> { promise.then(()=> {
console.info('Succeeded in hiding the window with animation. Data: ' + JSON.stringify(data)); console.info('Succeeded in hiding the window with animation.');
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err)); console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
}) });
``` ```
### showWindow<sup>9+</sup> ### showWindow<sup>9+</sup>
...@@ -1424,8 +1423,8 @@ showWithAnimation(callback: AsyncCallback&lt;void&gt;): void ...@@ -1424,8 +1423,8 @@ showWithAnimation(callback: AsyncCallback&lt;void&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
| 1300004 | This operation is not access. | | 1300004 | Unauthorized operation. |
**示例:** **示例:**
...@@ -1436,7 +1435,7 @@ windowClass.showWithAnimation((err) => { ...@@ -1436,7 +1435,7 @@ windowClass.showWithAnimation((err) => {
return; return;
} }
console.info('Succeeded in showing the window with animation.'); console.info('Succeeded in showing the window with animation.');
}) });
``` ```
### showWithAnimation<sup>9+</sup> ### showWithAnimation<sup>9+</sup>
...@@ -1462,8 +1461,8 @@ showWithAnimation(): Promise&lt;void&gt; ...@@ -1462,8 +1461,8 @@ showWithAnimation(): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
| 1300004 | This operation is not access. | | 1300004 | Unauthorized operation. |
**示例:** **示例:**
...@@ -1473,7 +1472,7 @@ promise.then(()=> { ...@@ -1473,7 +1472,7 @@ promise.then(()=> {
console.info('Succeeded in showing the window with animation.'); console.info('Succeeded in showing the window with animation.');
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err)); console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
}) });
``` ```
### destroyWindow<sup>9+</sup> ### destroyWindow<sup>9+</sup>
...@@ -1497,7 +1496,7 @@ destroyWindow(callback: AsyncCallback&lt;void&gt;): void ...@@ -1497,7 +1496,7 @@ destroyWindow(callback: AsyncCallback&lt;void&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -1508,7 +1507,7 @@ windowClass.destroyWindow((err) => { ...@@ -1508,7 +1507,7 @@ windowClass.destroyWindow((err) => {
return; return;
} }
console.info('Succeeded in destroying the window.'); console.info('Succeeded in destroying the window.');
}) });
``` ```
### destroyWindow<sup>9+</sup> ### destroyWindow<sup>9+</sup>
...@@ -1532,7 +1531,7 @@ destroyWindow(): Promise&lt;void&gt; ...@@ -1532,7 +1531,7 @@ destroyWindow(): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -1542,7 +1541,7 @@ promise.then(()=> { ...@@ -1542,7 +1541,7 @@ promise.then(()=> {
console.info('Succeeded in destroying the window.'); console.info('Succeeded in destroying the window.');
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
}) });
``` ```
### moveWindowTo<sup>9+</sup> ### moveWindowTo<sup>9+</sup>
...@@ -1568,7 +1567,7 @@ moveWindowTo(x: number, y: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -1568,7 +1567,7 @@ moveWindowTo(x: number, y: number, callback: AsyncCallback&lt;void&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -1583,7 +1582,7 @@ try { ...@@ -1583,7 +1582,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to move the window. Cause:' + JSON.stringify(exception)); console.error('Failed to move the window. Cause:' + JSON.stringify(exception));
}; }
``` ```
### moveWindowTo<sup>9+</sup> ### moveWindowTo<sup>9+</sup>
...@@ -1614,7 +1613,7 @@ moveWindowTo(x: number, y: number): Promise&lt;void&gt; ...@@ -1614,7 +1613,7 @@ moveWindowTo(x: number, y: number): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -1628,7 +1627,7 @@ try { ...@@ -1628,7 +1627,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to move the window. Cause:' + JSON.stringify(exception)); console.error('Failed to move the window. Cause:' + JSON.stringify(exception));
}; }
``` ```
### resize<sup>9+</sup> ### resize<sup>9+</sup>
...@@ -1637,6 +1636,12 @@ resize(width: number, height: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -1637,6 +1636,12 @@ resize(width: number, height: number, callback: AsyncCallback&lt;void&gt;): void
改变当前窗口大小,使用callback异步回调。 改变当前窗口大小,使用callback异步回调。
应用主窗口与子窗口存在大小限制,宽度范围:[320, 2560],高度范围:[240, 2560],单位为vp。
系统窗口存在大小限制,宽度范围:[0, 2560],高度范围:[0, 2560],单位为vp。
设置的宽度与高度受到此约束限制。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -1654,7 +1659,7 @@ resize(width: number, height: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -1654,7 +1659,7 @@ resize(width: number, height: number, callback: AsyncCallback&lt;void&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -1669,7 +1674,7 @@ try { ...@@ -1669,7 +1674,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to change the window size. Cause:' + JSON.stringify(exception)); console.error('Failed to change the window size. Cause:' + JSON.stringify(exception));
}; }
``` ```
### resize<sup>9+</sup> ### resize<sup>9+</sup>
...@@ -1678,6 +1683,12 @@ resize(width: number, height: number): Promise&lt;void&gt; ...@@ -1678,6 +1683,12 @@ resize(width: number, height: number): Promise&lt;void&gt;
改变当前窗口大小,使用Promise异步回调。 改变当前窗口大小,使用Promise异步回调。
应用主窗口与子窗口存在大小限制,宽度范围:[320, 2560],高度范围:[240, 2560],单位为vp。
系统窗口存在大小限制,宽度范围:[0, 2560],高度范围:[0, 2560],单位为vp。
设置的宽度与高度受到此约束限制。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -1700,7 +1711,7 @@ resize(width: number, height: number): Promise&lt;void&gt; ...@@ -1700,7 +1711,7 @@ resize(width: number, height: number): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -1714,7 +1725,7 @@ try { ...@@ -1714,7 +1725,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to change the window size. Cause: ' + JSON.stringify(exception)); console.error('Failed to change the window size. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setWindowMode<sup>9+</sup> ### setWindowMode<sup>9+</sup>
...@@ -1741,7 +1752,7 @@ setWindowMode(mode: WindowMode, callback: AsyncCallback&lt;void&gt;): void ...@@ -1741,7 +1752,7 @@ setWindowMode(mode: WindowMode, callback: AsyncCallback&lt;void&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -1757,7 +1768,7 @@ try { ...@@ -1757,7 +1768,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setWindowMode<sup>9+</sup> ### setWindowMode<sup>9+</sup>
...@@ -1789,14 +1800,14 @@ setWindowMode(mode: WindowMode): Promise&lt;void&gt; ...@@ -1789,14 +1800,14 @@ setWindowMode(mode: WindowMode): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
```js ```js
let mode = window.WindowMode.FULLSCREEN; let mode = window.WindowMode.FULLSCREEN;
try { try {
let promise = windowClass.setWindowMode(type); let promise = windowClass.setWindowMode(mode);
promise.then(()=> { promise.then(()=> {
console.info('Succeeded in setting the window mode.'); console.info('Succeeded in setting the window mode.');
}).catch((err)=>{ }).catch((err)=>{
...@@ -1804,7 +1815,7 @@ try { ...@@ -1804,7 +1815,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### getWindowProperties<sup>9+</sup> ### getWindowProperties<sup>9+</sup>
...@@ -1836,14 +1847,14 @@ try { ...@@ -1836,14 +1847,14 @@ try {
let properties = windowClass.getWindowProperties(); let properties = windowClass.getWindowProperties();
} catch (exception) { } catch (exception) {
console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(exception)); console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### getWindowAvoidArea<sup>9+</sup> ### getWindowAvoidArea<sup>9+</sup>
getWindowAvoidArea(type: AvoidAreaType): AvoidArea getWindowAvoidArea(type: AvoidAreaType): AvoidArea
获取窗口内容规避的区域,如系统的系统栏区域、刘海屏区域、手势区域、软键盘区域等 获取窗口内容规避的区域;如系统栏区域、刘海屏区域、手势区域、软键盘区域等与窗口内容重叠时,需要窗口内容避让的区域
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
...@@ -1875,7 +1886,7 @@ try { ...@@ -1875,7 +1886,7 @@ try {
let avoidArea = windowClass.getWindowAvoidArea(type); let avoidArea = windowClass.getWindowAvoidArea(type);
} catch (exception) { } catch (exception) {
console.error('Failed to obtain the area. Cause:' + JSON.stringify(exception)); console.error('Failed to obtain the area. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setWindowLayoutFullScreen<sup>9+</sup> ### setWindowLayoutFullScreen<sup>9+</sup>
...@@ -1900,7 +1911,7 @@ setWindowLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback&l ...@@ -1900,7 +1911,7 @@ setWindowLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback&l
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -1916,7 +1927,7 @@ try { ...@@ -1916,7 +1927,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception)); console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setWindowLayoutFullScreen<sup>9+</sup> ### setWindowLayoutFullScreen<sup>9+</sup>
...@@ -1946,7 +1957,7 @@ setWindowLayoutFullScreen(isLayoutFullScreen: boolean): Promise&lt;void&gt; ...@@ -1946,7 +1957,7 @@ setWindowLayoutFullScreen(isLayoutFullScreen: boolean): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -1961,7 +1972,7 @@ try { ...@@ -1961,7 +1972,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception)); console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setWindowSystemBarEnable<sup>9+</sup> ### setWindowSystemBarEnable<sup>9+</sup>
...@@ -1986,7 +1997,7 @@ setWindowSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncC ...@@ -1986,7 +1997,7 @@ setWindowSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncC
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -2003,7 +2014,7 @@ try { ...@@ -2003,7 +2014,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setWindowSystemBarEnable<sup>9+</sup> ### setWindowSystemBarEnable<sup>9+</sup>
...@@ -2033,7 +2044,7 @@ setWindowSystemBarEnable(names: Array<'status' | 'navigation'>): Promise&lt;void ...@@ -2033,7 +2044,7 @@ setWindowSystemBarEnable(names: Array<'status' | 'navigation'>): Promise&lt;void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -2049,7 +2060,7 @@ try { ...@@ -2049,7 +2060,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setWindowSystemBarProperties<sup>9+</sup> ### setWindowSystemBarProperties<sup>9+</sup>
...@@ -2074,12 +2085,12 @@ setWindowSystemBarProperties(systemBarProperties: SystemBarProperties, callback: ...@@ -2074,12 +2085,12 @@ setWindowSystemBarProperties(systemBarProperties: SystemBarProperties, callback:
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
```js ```js
let SystemBarProperties={ let SystemBarProperties = {
statusBarColor: '#ff00ff', statusBarColor: '#ff00ff',
navigationBarColor: '#00ff00', navigationBarColor: '#00ff00',
//以下两个属性从API Version8开始支持 //以下两个属性从API Version8开始支持
...@@ -2096,7 +2107,7 @@ try { ...@@ -2096,7 +2107,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setWindowSystemBarProperties<sup>9+</sup> ### setWindowSystemBarProperties<sup>9+</sup>
...@@ -2126,12 +2137,12 @@ setWindowSystemBarProperties(systemBarProperties: SystemBarProperties): Promise& ...@@ -2126,12 +2137,12 @@ setWindowSystemBarProperties(systemBarProperties: SystemBarProperties): Promise&
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
```js ```js
let SystemBarProperties={ let SystemBarProperties = {
statusBarColor: '#ff00ff', statusBarColor: '#ff00ff',
navigationBarColor: '#00ff00', navigationBarColor: '#00ff00',
//以下两个属性从API Version8开始支持 //以下两个属性从API Version8开始支持
...@@ -2147,7 +2158,7 @@ try { ...@@ -2147,7 +2158,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setPreferredOrientation<sup>9+</sup> ### setPreferredOrientation<sup>9+</sup>
...@@ -2187,7 +2198,7 @@ try { ...@@ -2187,7 +2198,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception)); console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setPreferredOrientation<sup>9+</sup> ### setPreferredOrientation<sup>9+</sup>
...@@ -2231,7 +2242,7 @@ try { ...@@ -2231,7 +2242,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception)); console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setUIContent<sup>9+</sup> ### setUIContent<sup>9+</sup>
...@@ -2256,7 +2267,7 @@ setUIContent(path: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -2256,7 +2267,7 @@ setUIContent(path: string, callback: AsyncCallback&lt;void&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -2271,7 +2282,7 @@ try { ...@@ -2271,7 +2282,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setUIContent<sup>9+</sup> ### setUIContent<sup>9+</sup>
...@@ -2301,7 +2312,7 @@ setUIContent(path: string): Promise&lt;void&gt; ...@@ -2301,7 +2312,7 @@ setUIContent(path: string): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -2315,7 +2326,7 @@ try { ...@@ -2315,7 +2326,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to load the content. Cause: ' + JSON.stringify(exception)); console.error('Failed to load the content. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### loadContent<sup>9+</sup> ### loadContent<sup>9+</sup>
...@@ -2343,29 +2354,24 @@ loadContent(path: string, storage: LocalStorage, callback: AsyncCallback&lt;void ...@@ -2343,29 +2354,24 @@ loadContent(path: string, storage: LocalStorage, callback: AsyncCallback&lt;void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
```ts ```ts
class myAbility extends Ability { let storage = new LocalStorage();
storage : LocalStorage storage.setOrCreate('storageSimpleProp',121);
onWindowStageCreate(windowStage) { console.log('onWindowStageCreate');
this.storage = new LocalStorage(); try {
this.storage.setOrCreate('storageSimpleProp',121); windowClass.loadContent('pages/page2', storage, (err) => {
console.log('onWindowStageCreate');
try {
windowStage.loadContent('pages/page2',this.storage,(err) => {
if (err.code) { if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err)); console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in loading the content.'); console.info('Succeeded in loading the content.');
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
};
}
} }
``` ```
...@@ -2399,30 +2405,23 @@ loadContent(path: string, storage: LocalStorage): Promise&lt;void&gt; ...@@ -2399,30 +2405,23 @@ loadContent(path: string, storage: LocalStorage): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
```ts ```ts
class myAbility extends Ability { let storage = new LocalStorage();
storage : LocalStorage storage.setOrCreate('storageSimpleProp',121);
onWindowStageCreate(windowStage) { console.log('onWindowStageCreate');
this.storage = new LocalStorage(); try {
this.storage.setOrCreate('storageSimpleProp',121); let promise = windowClass.loadContent('pages/page2', storage);
console.log('onWindowStageCreate'); promise.then(() => {
let windowClass = null;
try {
let promise = windowStage.loadContent('pages/page2',this.storage);
promise.then(()=> {
windowClass = data;
console.info('Succeeded in loading the content.'); console.info('Succeeded in loading the content.');
}).catch((err)=>{ }).catch((err) => {
console.error('Failed to load the content. Cause:' + JSON.stringify(err)); console.error('Failed to load the content. Cause:' + JSON.stringify(err));
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
};
}
} }
``` ```
...@@ -2456,7 +2455,7 @@ try { ...@@ -2456,7 +2455,7 @@ try {
console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)); console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
} catch (exception) { } catch (exception) {
console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(exception)); console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### on('windowSizeChange')<sup>7+</sup> ### on('windowSizeChange')<sup>7+</sup>
...@@ -2483,7 +2482,7 @@ try { ...@@ -2483,7 +2482,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to enable the listener for window size changes. Cause: ' + JSON.stringify(exception)); console.error('Failed to enable the listener for window size changes. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### off('windowSizeChange')<sup>7+</sup> ### off('windowSizeChange')<sup>7+</sup>
...@@ -2508,7 +2507,7 @@ try { ...@@ -2508,7 +2507,7 @@ try {
windowClass.off('windowSizeChange'); windowClass.off('windowSizeChange');
} catch (exception) { } catch (exception) {
console.error('Failed to disable the listener for window size changes. Cause: ' + JSON.stringify(exception)); console.error('Failed to disable the listener for window size changes. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### on('avoidAreaChange')<sup>9+</sup> ### on('avoidAreaChange')<sup>9+</sup>
...@@ -2536,7 +2535,7 @@ try { ...@@ -2536,7 +2535,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to enable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception)); console.error('Failed to enable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### off('avoidAreaChange')<sup>9+</sup> ### off('avoidAreaChange')<sup>9+</sup>
...@@ -2561,7 +2560,7 @@ try { ...@@ -2561,7 +2560,7 @@ try {
windowClass.off('avoidAreaChange'); windowClass.off('avoidAreaChange');
} catch (exception) { } catch (exception) {
console.error('Failed to disable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception)); console.error('Failed to disable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### on('keyboardHeightChange')<sup>7+</sup> ### on('keyboardHeightChange')<sup>7+</sup>
...@@ -2588,7 +2587,7 @@ try { ...@@ -2588,7 +2587,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to enable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception)); console.error('Failed to enable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### off('keyboardHeightChange')<sup>7+</sup> ### off('keyboardHeightChange')<sup>7+</sup>
...@@ -2613,7 +2612,7 @@ try { ...@@ -2613,7 +2612,7 @@ try {
windowClass.off('keyboardHeightChange'); windowClass.off('keyboardHeightChange');
} catch (exception) { } catch (exception) {
console.error('Failed to disable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception)); console.error('Failed to disable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### on('touchOutside')<sup>9+</sup> ### on('touchOutside')<sup>9+</sup>
...@@ -2642,7 +2641,7 @@ try { ...@@ -2642,7 +2641,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### off('touchOutside')<sup>9+</sup> ### off('touchOutside')<sup>9+</sup>
...@@ -2669,7 +2668,7 @@ try { ...@@ -2669,7 +2668,7 @@ try {
windowClass.off('touchOutside'); windowClass.off('touchOutside');
} catch (exception) { } catch (exception) {
console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception)); console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### on('screenshot')<sup>9+</sup> ### on('screenshot')<sup>9+</sup>
...@@ -2696,7 +2695,7 @@ try { ...@@ -2696,7 +2695,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### off('screenshot')<sup>9+</sup> ### off('screenshot')<sup>9+</sup>
...@@ -2717,21 +2716,21 @@ off(type: 'screenshot', callback?: Callback&lt;void&gt;): void ...@@ -2717,21 +2716,21 @@ off(type: 'screenshot', callback?: Callback&lt;void&gt;): void
**示例:** **示例:**
```js ```js
let callback = ()=>{ let callback = () => {
console.info('screenshot happened'); console.info('screenshot happened');
} };
try { try {
windowClass.on('screenshot', callback); windowClass.on('screenshot', callback);
} catch (exception) { } catch (exception) {
console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
}; }
try { try {
windowClass.off('screenshot', callback); windowClass.off('screenshot', callback);
// 如果通过on开启多个callback进行监听,同时关闭所有监听: // 如果通过on开启多个callback进行监听,同时关闭所有监听:
windowClass.off('screenshot'); windowClass.off('screenshot');
} catch (exception) { } catch (exception) {
console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception)); console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### on('dialogTargetTouch')<sup>9+</sup> ### on('dialogTargetTouch')<sup>9+</sup>
...@@ -2758,7 +2757,7 @@ try { ...@@ -2758,7 +2757,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### off('dialogTargetTouch')<sup>9+</sup> ### off('dialogTargetTouch')<sup>9+</sup>
...@@ -2783,7 +2782,7 @@ try { ...@@ -2783,7 +2782,7 @@ try {
windowClass.off('dialogTargetTouch'); windowClass.off('dialogTargetTouch');
} catch (exception) { } catch (exception) {
console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception)); console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### bindDialogTarget<sup>9+</sup> ### bindDialogTarget<sup>9+</sup>
...@@ -2811,11 +2810,13 @@ bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback&lt;void&gt;, c ...@@ -2811,11 +2810,13 @@ bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback&lt;void&gt;, c
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
```js ```js
import rpc from '@ohos.rpc';
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log('server died'); console.log('server died');
...@@ -2835,6 +2836,7 @@ class TestRemoteObject extends rpc.RemoteObject { ...@@ -2835,6 +2836,7 @@ class TestRemoteObject extends rpc.RemoteObject {
return false; return false;
} }
} }
let token = new TestRemoteObject('testObject'); let token = new TestRemoteObject('testObject');
try { try {
windowClass.bindDialogTarget(token, () => { windowClass.bindDialogTarget(token, () => {
...@@ -2848,7 +2850,7 @@ try { ...@@ -2848,7 +2850,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception)); console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception));
}; }
``` ```
### bindDialogTarget<sup>9+</sup> ### bindDialogTarget<sup>9+</sup>
...@@ -2881,11 +2883,13 @@ bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback&lt;void&gt;): ...@@ -2881,11 +2883,13 @@ bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback&lt;void&gt;):
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
```js ```js
import rpc from '@ohos.rpc';
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log('server died'); console.log('server died');
...@@ -2905,6 +2909,7 @@ class TestRemoteObject extends rpc.RemoteObject { ...@@ -2905,6 +2909,7 @@ class TestRemoteObject extends rpc.RemoteObject {
return false; return false;
} }
} }
let token = new TestRemoteObject('testObject'); let token = new TestRemoteObject('testObject');
try { try {
let promise = windowClass.bindDialogTarget(token, () => { let promise = windowClass.bindDialogTarget(token, () => {
...@@ -2917,7 +2922,7 @@ try { ...@@ -2917,7 +2922,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception)); console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception));
}; }
``` ```
### isWindowSupportWideGamut<sup>9+</sup> ### isWindowSupportWideGamut<sup>9+</sup>
...@@ -3023,7 +3028,7 @@ try { ...@@ -3023,7 +3028,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception)); console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setWindowColorSpace<sup>9+</sup> ### setWindowColorSpace<sup>9+</sup>
...@@ -3066,7 +3071,7 @@ try { ...@@ -3066,7 +3071,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception)); console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception));
}; }
``` ```
### getWindowColorSpace<sup>9+</sup> ### getWindowColorSpace<sup>9+</sup>
...@@ -3127,7 +3132,7 @@ try { ...@@ -3127,7 +3132,7 @@ try {
windowClass.setWindowBackgroundColor(color); windowClass.setWindowBackgroundColor(color);
} catch (exception) { } catch (exception) {
console.error('Failed to set the background color. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the background color. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setWindowBrightness<sup>9+</sup> ### setWindowBrightness<sup>9+</sup>
...@@ -3152,7 +3157,7 @@ setWindowBrightness(brightness: number, callback: AsyncCallback&lt;void&gt;): vo ...@@ -3152,7 +3157,7 @@ setWindowBrightness(brightness: number, callback: AsyncCallback&lt;void&gt;): vo
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -3168,7 +3173,7 @@ try { ...@@ -3168,7 +3173,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setWindowBrightness<sup>9+</sup> ### setWindowBrightness<sup>9+</sup>
...@@ -3198,7 +3203,7 @@ setWindowBrightness(brightness: number): Promise&lt;void&gt; ...@@ -3198,7 +3203,7 @@ setWindowBrightness(brightness: number): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -3213,7 +3218,7 @@ try { ...@@ -3213,7 +3218,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setWindowFocusable<sup>9+</sup> ### setWindowFocusable<sup>9+</sup>
...@@ -3238,12 +3243,12 @@ setWindowFocusable(isFocusable: boolean, callback: AsyncCallback&lt;void&gt;): v ...@@ -3238,12 +3243,12 @@ setWindowFocusable(isFocusable: boolean, callback: AsyncCallback&lt;void&gt;): v
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
```js ```js
let isFocusable= true; let isFocusable = true;
try { try {
windowClass.setWindowFocusable(isFocusable, (err) => { windowClass.setWindowFocusable(isFocusable, (err) => {
if (err.code) { if (err.code) {
...@@ -3254,7 +3259,7 @@ try { ...@@ -3254,7 +3259,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception)); console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setWindowFocusable<sup>9+</sup> ### setWindowFocusable<sup>9+</sup>
...@@ -3284,12 +3289,12 @@ setWindowFocusable(isFocusable: boolean): Promise&lt;void&gt; ...@@ -3284,12 +3289,12 @@ setWindowFocusable(isFocusable: boolean): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
```js ```js
let isFocusable= true; let isFocusable = true;
try { try {
let promise = windowClass.setWindowFocusable(isFocusable); let promise = windowClass.setWindowFocusable(isFocusable);
promise.then(()=> { promise.then(()=> {
...@@ -3299,7 +3304,7 @@ try { ...@@ -3299,7 +3304,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception)); console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setWindowKeepScreenOn<sup>9+</sup> ### setWindowKeepScreenOn<sup>9+</sup>
...@@ -3324,7 +3329,7 @@ setWindowKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback&lt;void&g ...@@ -3324,7 +3329,7 @@ setWindowKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback&lt;void&g
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -3340,7 +3345,7 @@ try { ...@@ -3340,7 +3345,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setWindowKeepScreenOn<sup>9+</sup> ### setWindowKeepScreenOn<sup>9+</sup>
...@@ -3370,7 +3375,7 @@ setWindowKeepScreenOn(isKeepScreenOn: boolean): Promise&lt;void&gt; ...@@ -3370,7 +3375,7 @@ setWindowKeepScreenOn(isKeepScreenOn: boolean): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -3385,7 +3390,7 @@ try { ...@@ -3385,7 +3390,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception)); console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setWakeUpScreen()<sup>9+</sup> ### setWakeUpScreen()<sup>9+</sup>
...@@ -3411,7 +3416,7 @@ setWakeUpScreen(wakeUp: boolean): void ...@@ -3411,7 +3416,7 @@ setWakeUpScreen(wakeUp: boolean): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -3421,7 +3426,7 @@ try { ...@@ -3421,7 +3426,7 @@ try {
windowClass.setWakeUpScreen(wakeUp); windowClass.setWakeUpScreen(wakeUp);
} catch (exception) { } catch (exception) {
console.error('Failed to wake up the screen. Cause: ' + JSON.stringify(exception)); console.error('Failed to wake up the screen. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setWindowPrivacyMode<sup>9+</sup> ### setWindowPrivacyMode<sup>9+</sup>
...@@ -3432,7 +3437,7 @@ setWindowPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback&lt;void&gt; ...@@ -3432,7 +3437,7 @@ setWindowPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback&lt;void&gt;
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**需要权限:** ohos.permission.PRIVACE_WINDOW **需要权限:** ohos.permission.PRIVACY_WINDOW
**参数:** **参数:**
...@@ -3463,7 +3468,7 @@ try { ...@@ -3463,7 +3468,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception)); console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setWindowPrivacyMode<sup>9+</sup> ### setWindowPrivacyMode<sup>9+</sup>
...@@ -3474,7 +3479,7 @@ setWindowPrivacyMode(isPrivacyMode: boolean): Promise&lt;void&gt; ...@@ -3474,7 +3479,7 @@ setWindowPrivacyMode(isPrivacyMode: boolean): Promise&lt;void&gt;
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**需要权限:** ohos.permission.PRIVACE_WINDOW **需要权限:** ohos.permission.PRIVACY_WINDOW
**参数:** **参数:**
...@@ -3509,7 +3514,7 @@ try { ...@@ -3509,7 +3514,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception)); console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setSnapshotSkip<sup>9+</sup> ### setSnapshotSkip<sup>9+</sup>
...@@ -3566,7 +3571,7 @@ setWindowTouchable(isTouchable: boolean, callback: AsyncCallback&lt;void&gt;): v ...@@ -3566,7 +3571,7 @@ setWindowTouchable(isTouchable: boolean, callback: AsyncCallback&lt;void&gt;): v
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -3582,7 +3587,7 @@ try { ...@@ -3582,7 +3587,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception)); console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setWindowTouchable<sup>9+</sup> ### setWindowTouchable<sup>9+</sup>
...@@ -3612,7 +3617,7 @@ setWindowTouchable(isTouchable: boolean): Promise&lt;void&gt; ...@@ -3612,7 +3617,7 @@ setWindowTouchable(isTouchable: boolean): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -3627,7 +3632,7 @@ try { ...@@ -3627,7 +3632,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception)); console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setForbidSplitMove<sup>9+</sup> ### setForbidSplitMove<sup>9+</sup>
...@@ -3654,7 +3659,7 @@ setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback&lt;void&g ...@@ -3654,7 +3659,7 @@ setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback&lt;void&g
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -3670,7 +3675,7 @@ try { ...@@ -3670,7 +3675,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception)); console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception));
}; }
``` ```
### setForbidSplitMove<sup>9+</sup> ### setForbidSplitMove<sup>9+</sup>
...@@ -3702,7 +3707,7 @@ setForbidSplitMove(isForbidSplitMove: boolean): Promise&lt;void&gt; ...@@ -3702,7 +3707,7 @@ setForbidSplitMove(isForbidSplitMove: boolean): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------------------- | | ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300003 | This window manager service work abnormally. | | 1300003 | This window manager service works abnormally. |
**示例:** **示例:**
...@@ -3717,7 +3722,7 @@ try { ...@@ -3717,7 +3722,7 @@ try {
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception)); console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception));
}; }
``` ```
### snapshot<sup>9+</sup> ### snapshot<sup>9+</sup>
...@@ -3745,13 +3750,13 @@ snapshot(callback: AsyncCallback&lt;image.PixelMap&gt;): void ...@@ -3745,13 +3750,13 @@ snapshot(callback: AsyncCallback&lt;image.PixelMap&gt;): void
**示例:** **示例:**
```js ```js
windowClass.snapshot((err, data) => { windowClass.snapshot((err, pixelMap) => {
if (err.code) { if (err.code) {
console.error('Failed to snapshot window. Cause:' + JSON.stringify(err)); console.error('Failed to snapshot window. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
data.release(); // PixelMap使用完后及时释放内存 pixelMap.release(); // PixelMap使用完后及时释放内存
}); });
``` ```
...@@ -3812,7 +3817,7 @@ opacity(opacity: number): void ...@@ -3812,7 +3817,7 @@ opacity(opacity: number): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ------------------------------ | | ------- | ------------------------------ |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300004 | This operation is not access. | | 1300004 | Unauthorized operation. |
**示例:** **示例:**
...@@ -3821,7 +3826,7 @@ try { ...@@ -3821,7 +3826,7 @@ try {
windowClass.opacity(0.5); windowClass.opacity(0.5);
} catch (exception) { } catch (exception) {
console.error('Failed to opacity. Cause: ' + JSON.stringify(exception)); console.error('Failed to opacity. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### scale<sup>9+</sup> ### scale<sup>9+</sup>
...@@ -3847,7 +3852,7 @@ scale(scaleOptions: ScaleOptions): void ...@@ -3847,7 +3852,7 @@ scale(scaleOptions: ScaleOptions): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ------------------------------ | | ------- | ------------------------------ |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300004 | This operation is not access. | | 1300004 | Unauthorized operation. |
**示例:** **示例:**
...@@ -3855,14 +3860,14 @@ scale(scaleOptions: ScaleOptions): void ...@@ -3855,14 +3860,14 @@ scale(scaleOptions: ScaleOptions): void
let obj : window.ScaleOptions = { let obj : window.ScaleOptions = {
x : 2.0, x : 2.0,
y : 1.0, y : 1.0,
pivotX = 0.5; pivotX : 0.5,
pivotY = 0.5; pivotY : 0.5
} };
try { try {
windowClass.scale(obj); windowClass.scale(obj);
} catch (exception) { } catch (exception) {
console.error('Failed to scale. Cause: ' + JSON.stringify(exception)); console.error('Failed to scale. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### rotate<sup>9+</sup> ### rotate<sup>9+</sup>
...@@ -3888,7 +3893,7 @@ rotate(rotateOptions: RotateOptions): void ...@@ -3888,7 +3893,7 @@ rotate(rotateOptions: RotateOptions): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ------------------------------ | | ------- | ------------------------------ |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300004 | This operation is not access. | | 1300004 | Unauthorized operation. |
**示例:** **示例:**
...@@ -3897,14 +3902,14 @@ let obj : window.RotateOptions = { ...@@ -3897,14 +3902,14 @@ let obj : window.RotateOptions = {
x : 1.0, x : 1.0,
y : 1.0, y : 1.0,
z : 45.0, z : 45.0,
pivotX = 0.5; pivotX : 0.5,
pivotY = 0.5; pivotY : 0.5
} };
try { try {
windowClass.rotate(obj); windowClass.rotate(obj);
} catch (exception) { } catch (exception) {
console.error('Failed to rotate. Cause: ' + JSON.stringify(exception)); console.error('Failed to rotate. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### translate<sup>9+</sup> ### translate<sup>9+</sup>
...@@ -3930,7 +3935,7 @@ translate(translateOptions: TranslateOptions): void ...@@ -3930,7 +3935,7 @@ translate(translateOptions: TranslateOptions): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ------------------------------ | | ------- | ------------------------------ |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300004 | This operation is not access. | | 1300004 | Unauthorized operation. |
**示例:** **示例:**
...@@ -3939,12 +3944,12 @@ let obj : window.TranslateOptions = { ...@@ -3939,12 +3944,12 @@ let obj : window.TranslateOptions = {
x : 100.0, x : 100.0,
y : 0.0, y : 0.0,
z : 0.0 z : 0.0
} };
try { try {
windowClass.translate(obj); windowClass.translate(obj);
} catch (exception) { } catch (exception) {
console.error('Failed to translate. Cause: ' + JSON.stringify(exception)); console.error('Failed to translate. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### getTransitionController<sup>9+</sup> ### getTransitionController<sup>9+</sup>
...@@ -3970,14 +3975,14 @@ try { ...@@ -3970,14 +3975,14 @@ try {
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ------------------------------ | | ------- | ------------------------------ |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300004 | This operation is not access. | | 1300004 | Unauthorized operation. |
**示例:** **示例:**
```js ```js
let controller = windowClass.getTransitionController(); // 获取属性转换控制器 let controller = windowClass.getTransitionController(); // 获取属性转换控制器
controller.animationForHidden = (context : window.TransitionContext) => { controller.animationForHidden = (context : window.TransitionContext) => {
let toWindow = context.toWindow let toWindow = context.toWindow;
animateTo({ animateTo({
duration: 1000, // 动画时长 duration: 1000, // 动画时长
tempo: 0.5, // 播放速率 tempo: 0.5, // 播放速率
...@@ -3993,20 +3998,20 @@ controller.animationForHidden = (context : window.TransitionContext) => { ...@@ -3993,20 +3998,20 @@ controller.animationForHidden = (context : window.TransitionContext) => {
x : 100.0, x : 100.0,
y : 0.0, y : 0.0,
z : 0.0 z : 0.0
} };
toWindow.translate(obj); // 设置动画过程中的属性转换 toWindow.translate(obj); // 设置动画过程中的属性转换
console.info('toWindow translate end'); console.info('toWindow translate end');
} }
) );
console.info('complete transition end'); console.info('complete transition end');
} };
windowClass.hideWithAnimation((err, data) => { windowClass.hideWithAnimation((err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err)); console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data)); console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data));
}) });
``` ```
### setBlur<sup>9+</sup> ### setBlur<sup>9+</sup>
...@@ -4032,7 +4037,7 @@ setBlur(radius: number): void ...@@ -4032,7 +4037,7 @@ setBlur(radius: number): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ------------------------------ | | ------- | ------------------------------ |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300004 | This operation is not access. | | 1300004 | Unauthorized operation. |
**示例:** **示例:**
...@@ -4041,7 +4046,7 @@ try { ...@@ -4041,7 +4046,7 @@ try {
windowClass.setBlur(4.0); windowClass.setBlur(4.0);
} catch (exception) { } catch (exception) {
console.error('Failed to set blur. Cause: ' + JSON.stringify(exception)); console.error('Failed to set blur. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setBackdropBlur<sup>9+</sup> ### setBackdropBlur<sup>9+</sup>
...@@ -4067,7 +4072,7 @@ setBackdropBlur(radius: number): void ...@@ -4067,7 +4072,7 @@ setBackdropBlur(radius: number): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ------------------------------ | | ------- | ------------------------------ |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300004 | This operation is not access. | | 1300004 | Unauthorized operation. |
**示例:** **示例:**
...@@ -4076,7 +4081,7 @@ try { ...@@ -4076,7 +4081,7 @@ try {
windowClass.setBackdropBlur(4.0); windowClass.setBackdropBlur(4.0);
} catch (exception) { } catch (exception) {
console.error('Failed to set backdrop blur. Cause: ' + JSON.stringify(exception)); console.error('Failed to set backdrop blur. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setBackdropBlurStyle<sup>9+</sup> ### setBackdropBlurStyle<sup>9+</sup>
...@@ -4102,16 +4107,16 @@ setBackdropBlurStyle(blurStyle: BlurStyle): void ...@@ -4102,16 +4107,16 @@ setBackdropBlurStyle(blurStyle: BlurStyle): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ------------------------------ | | ------- | ------------------------------ |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300004 | This operation is not access. | | 1300004 | Unauthorized operation. |
**示例:** **示例:**
```js ```js
try { try {
windowClass.setBackdropBlurStyle(window.BlurType.THIN); windowClass.setBackdropBlurStyle(window.BlurStyle.THIN);
} catch (exception) { } catch (exception) {
console.error('Failed to set backdrop blur style. Cause: ' + JSON.stringify(exception)); console.error('Failed to set backdrop blur style. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setShadow<sup>9+</sup> ### setShadow<sup>9+</sup>
...@@ -4140,7 +4145,7 @@ setShadow(radius: number, color?: string, offsetX?: number, offsetY?: number): v ...@@ -4140,7 +4145,7 @@ setShadow(radius: number, color?: string, offsetX?: number, offsetY?: number): v
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ------------------------------ | | ------- | ------------------------------ |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300004 | This operation is not access. | | 1300004 | Unauthorized operation. |
**示例:** **示例:**
...@@ -4149,7 +4154,7 @@ try { ...@@ -4149,7 +4154,7 @@ try {
windowClass.setShadow(4.0, '#FF00FF00', 2, 3); windowClass.setShadow(4.0, '#FF00FF00', 2, 3);
} catch (exception) { } catch (exception) {
console.error('Failed to set shadow. Cause: ' + JSON.stringify(exception)); console.error('Failed to set shadow. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### setCornerRadius<sup>9+</sup> ### setCornerRadius<sup>9+</sup>
...@@ -4175,7 +4180,7 @@ setCornerRadius(cornerRadius: number): void ...@@ -4175,7 +4180,7 @@ setCornerRadius(cornerRadius: number): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ------------------------------ | | ------- | ------------------------------ |
| 1300002 | This window state is abnormal. | | 1300002 | This window state is abnormal. |
| 1300004 | This operation is not access. | | 1300004 | Unauthorized operation. |
**示例:** **示例:**
...@@ -4184,7 +4189,7 @@ try { ...@@ -4184,7 +4189,7 @@ try {
windowClass.setCornerRadius(4.0); windowClass.setCornerRadius(4.0);
} catch (exception) { } catch (exception) {
console.error('Failed to set corner radius. Cause: ' + JSON.stringify(exception)); console.error('Failed to set corner radius. Cause: ' + JSON.stringify(exception));
}; }
``` ```
### show<sup>(deprecated)</sup> ### show<sup>(deprecated)</sup>
...@@ -4214,7 +4219,7 @@ windowClass.show((err) => { ...@@ -4214,7 +4219,7 @@ windowClass.show((err) => {
return; return;
} }
console.info('Succeeded in showing the window.'); console.info('Succeeded in showing the window.');
}) });
``` ```
### show<sup>(deprecated)</sup> ### show<sup>(deprecated)</sup>
...@@ -4243,7 +4248,7 @@ promise.then(()=> { ...@@ -4243,7 +4248,7 @@ promise.then(()=> {
console.info('Succeeded in showing the window.'); console.info('Succeeded in showing the window.');
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
}) });
``` ```
### destroy<sup>(deprecated)</sup> ### destroy<sup>(deprecated)</sup>
...@@ -4273,7 +4278,7 @@ windowClass.destroy((err) => { ...@@ -4273,7 +4278,7 @@ windowClass.destroy((err) => {
return; return;
} }
console.info('Succeeded in destroying the window.'); console.info('Succeeded in destroying the window.');
}) });
``` ```
### destroy<sup>(deprecated)</sup> ### destroy<sup>(deprecated)</sup>
...@@ -4302,7 +4307,7 @@ promise.then(()=> { ...@@ -4302,7 +4307,7 @@ promise.then(()=> {
console.info('Succeeded in destroying the window.'); console.info('Succeeded in destroying the window.');
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
}) });
``` ```
### moveTo<sup>(deprecated)</sup> ### moveTo<sup>(deprecated)</sup>
...@@ -4334,7 +4339,6 @@ windowClass.moveTo(300, 300, (err)=>{ ...@@ -4334,7 +4339,6 @@ windowClass.moveTo(300, 300, (err)=>{
return; return;
} }
console.info('Succeeded in moving the window.'); console.info('Succeeded in moving the window.');
}); });
``` ```
...@@ -4371,7 +4375,7 @@ promise.then(()=> { ...@@ -4371,7 +4375,7 @@ promise.then(()=> {
console.info('Succeeded in moving the window.'); console.info('Succeeded in moving the window.');
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to move the window. Cause: ' + JSON.stringify(err)); console.error('Failed to move the window. Cause: ' + JSON.stringify(err));
}) });
``` ```
### resetSize<sup>(deprecated)</sup> ### resetSize<sup>(deprecated)</sup>
...@@ -4380,6 +4384,12 @@ resetSize(width: number, height: number, callback: AsyncCallback&lt;void&gt;): v ...@@ -4380,6 +4384,12 @@ resetSize(width: number, height: number, callback: AsyncCallback&lt;void&gt;): v
改变当前窗口大小,使用callback异步回调。 改变当前窗口大小,使用callback异步回调。
应用主窗口与子窗口存在大小限制,宽度范围:[320, 2560],高度范围:[240, 2560],单位为vp。
系统窗口存在大小限制,宽度范围:[0, 2560],高度范围:[0, 2560],单位为vp。
设置的宽度与高度受到此约束限制。
> **说明:** > **说明:**
> >
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[resize()](#resize9)。 > 从 API version 7开始支持,从API version 9开始废弃,推荐使用[resize()](#resize9)。
...@@ -4412,6 +4422,12 @@ resetSize(width: number, height: number): Promise&lt;void&gt; ...@@ -4412,6 +4422,12 @@ resetSize(width: number, height: number): Promise&lt;void&gt;
改变当前窗口大小,使用Promise异步回调。 改变当前窗口大小,使用Promise异步回调。
应用主窗口与子窗口存在大小限制,宽度范围:[320, 2560],高度范围:[240, 2560],单位为vp。
系统窗口存在大小限制,宽度范围:[0, 2560],高度范围:[0, 2560],单位为vp。
设置的宽度与高度受到此约束限制。
> **说明:** > **说明:**
> >
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[resize()](#resize9-1)。 > 从 API version 7开始支持,从API version 9开始废弃,推荐使用[resize()](#resize9-1)。
...@@ -4577,7 +4593,7 @@ promise.then((data)=> { ...@@ -4577,7 +4593,7 @@ promise.then((data)=> {
getAvoidArea(type: [AvoidAreaType](#avoidareatype7), callback: AsyncCallback&lt;[AvoidArea](#avoidarea7)&gt;): void getAvoidArea(type: [AvoidAreaType](#avoidareatype7), callback: AsyncCallback&lt;[AvoidArea](#avoidarea7)&gt;): void
获取窗口内容规避的区域,如系统的系统栏区域、刘海屏区域、手势区域、软键盘区域等 获取窗口内容规避的区域;如系统栏区域、刘海屏区域、手势区域、软键盘区域等与窗口内容重叠时,需要窗口内容避让的区域
> **说明:** > **说明:**
> >
...@@ -4609,11 +4625,11 @@ windowClass.getAvoidArea(type, (err, data) => { ...@@ -4609,11 +4625,11 @@ windowClass.getAvoidArea(type, (err, data) => {
getAvoidArea(type: [AvoidAreaType](#avoidareatype7)): Promise&lt;[AvoidArea](#avoidarea7)&gt; getAvoidArea(type: [AvoidAreaType](#avoidareatype7)): Promise&lt;[AvoidArea](#avoidarea7)&gt;
获取窗口内容规避的区域,如系统的系统栏区域、刘海屏区域、手势区域、软键盘区域等 获取窗口内容规避的区域;如系统栏区域、刘海屏区域、手势区域、软键盘区域等与窗口内容重叠时,需要窗口内容避让的区域
> **说明:** > **说明:**
> >
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getWindowProperties()](#getwindowavoidarea9)。 > 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getWindowAvoidArea()](#getwindowavoidarea9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
...@@ -5131,7 +5147,7 @@ windowClass.isSupportWideGamut((err, data) => { ...@@ -5131,7 +5147,7 @@ windowClass.isSupportWideGamut((err, data) => {
return; return;
} }
console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data)); console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data));
}) });
``` ```
### isSupportWideGamut<sup>(deprecated)</sup> ### isSupportWideGamut<sup>(deprecated)</sup>
...@@ -5191,7 +5207,7 @@ windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err) => { ...@@ -5191,7 +5207,7 @@ windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err) => {
return; return;
} }
console.info('Succeeded in setting window colorspace.'); console.info('Succeeded in setting window colorspace.');
}) });
``` ```
### setColorSpace<sup>(deprecated)</sup> ### setColorSpace<sup>(deprecated)</sup>
...@@ -5256,7 +5272,7 @@ windowClass.getColorSpace((err, data) => { ...@@ -5256,7 +5272,7 @@ windowClass.getColorSpace((err, data) => {
return; return;
} }
console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data)); console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data));
}) });
``` ```
### getColorSpace<sup>(deprecated)</sup> ### getColorSpace<sup>(deprecated)</sup>
...@@ -5654,7 +5670,7 @@ windowClass.setOutsideTouchable(true, (err) => { ...@@ -5654,7 +5670,7 @@ windowClass.setOutsideTouchable(true, (err) => {
return; return;
} }
console.info('Succeeded in setting the area to be touchable.'); console.info('Succeeded in setting the area to be touchable.');
}) });
``` ```
### setOutsideTouchable<sup>(deprecated)</sup> ### setOutsideTouchable<sup>(deprecated)</sup>
...@@ -5721,7 +5737,6 @@ windowClass.setPrivacyMode(isPrivacyMode, (err) => { ...@@ -5721,7 +5737,6 @@ windowClass.setPrivacyMode(isPrivacyMode, (err) => {
return; return;
} }
console.info('Succeeded in setting the window to privacy mode.'); console.info('Succeeded in setting the window to privacy mode.');
}); });
``` ```
...@@ -5790,7 +5805,6 @@ windowClass.setTouchable(isTouchable, (err) => { ...@@ -5790,7 +5805,6 @@ windowClass.setTouchable(isTouchable, (err) => {
return; return;
} }
console.info('Succeeded in setting the window to be touchable.'); console.info('Succeeded in setting the window to be touchable.');
}); });
``` ```
...@@ -5840,10 +5854,10 @@ WindowStage生命周期。 ...@@ -5840,10 +5854,10 @@ WindowStage生命周期。
| 名称 | 默认值 | 说明 | | 名称 | 默认值 | 说明 |
| ---------- | ------ | ---------- | | ---------- | ------ | ---------- |
| FOREGROUND | 1 | 切到前台。 | | SHOWN | 1 | 切到前台。 |
| ACTIVE | 2 | 获焦状态。 | | ACTIVE | 2 | 获焦状态。 |
| INACTIVE | 3 | 失焦状态。 | | INACTIVE | 3 | 失焦状态。 |
| BACKGROUND | 4 | 切到后台。 | | HIDDEN | 4 | 切到后台。 |
## WindowStage<sup>9+</sup> ## WindowStage<sup>9+</sup>
...@@ -5880,6 +5894,7 @@ getMainWindow(callback: AsyncCallback&lt;Window&gt;): void ...@@ -5880,6 +5894,7 @@ getMainWindow(callback: AsyncCallback&lt;Window&gt;): void
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
...@@ -5893,7 +5908,7 @@ class myAbility extends Ability { ...@@ -5893,7 +5908,7 @@ class myAbility extends Ability {
console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
}); });
} }
} };
``` ```
### getMainWindow<sup>9+</sup> ### getMainWindow<sup>9+</sup>
...@@ -5925,19 +5940,20 @@ getMainWindow(): Promise&lt;Window&gt; ...@@ -5925,19 +5940,20 @@ getMainWindow(): Promise&lt;Window&gt;
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
let windowClass = null; let windowClass = null;
let promise = windowStage.getMainWindow(); let promise = windowStage.getMainWindow();
promise.then((data)=> { promise.then((data) => {
windowClass = data; windowClass = data;
console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err) => {
console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err)); console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
}); });
} }
} };
``` ```
### getMainWindowSync<sup>9+</sup> ### getMainWindowSync<sup>9+</sup>
...@@ -5969,6 +5985,7 @@ getMainWindowSync(): Window ...@@ -5969,6 +5985,7 @@ getMainWindowSync(): Window
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
...@@ -5978,7 +5995,7 @@ class myAbility extends Ability { ...@@ -5978,7 +5995,7 @@ class myAbility extends Ability {
console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(exception)); console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(exception));
}; };
} }
} };
``` ```
### createSubWindow<sup>9+</sup> ### createSubWindow<sup>9+</sup>
...@@ -6011,6 +6028,7 @@ createSubWindow(name: string, callback: AsyncCallback&lt;Window&gt;): void ...@@ -6011,6 +6028,7 @@ createSubWindow(name: string, callback: AsyncCallback&lt;Window&gt;): void
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
...@@ -6029,7 +6047,7 @@ class myAbility extends Ability { ...@@ -6029,7 +6047,7 @@ class myAbility extends Ability {
console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception)); console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception));
}; };
} }
} };
``` ```
### createSubWindow<sup>9+</sup> ### createSubWindow<sup>9+</sup>
...@@ -6066,23 +6084,24 @@ createSubWindow(name: string): Promise&lt;Window&gt; ...@@ -6066,23 +6084,24 @@ createSubWindow(name: string): Promise&lt;Window&gt;
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
let windowClass = null; let windowClass = null;
try { try {
let promise = windowStage.createSubWindow('mySubWindow'); let promise = windowStage.createSubWindow('mySubWindow');
promise.then((data)=> { promise.then((data) => {
windowClass = data; windowClass = data;
console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data)); console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err) => {
console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err)); console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err));
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception)); console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception));
}; };
} }
} };
``` ```
### getSubWindow<sup>9+</sup> ### getSubWindow<sup>9+</sup>
...@@ -6113,6 +6132,7 @@ getSubWindow(callback: AsyncCallback&lt;Array&lt;Window&gt;&gt;): void ...@@ -6113,6 +6132,7 @@ getSubWindow(callback: AsyncCallback&lt;Array&lt;Window&gt;&gt;): void
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
...@@ -6126,7 +6146,7 @@ class myAbility extends Ability { ...@@ -6126,7 +6146,7 @@ class myAbility extends Ability {
console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data)); console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data));
}); });
} }
} };
``` ```
### getSubWindow<sup>9+</sup> ### getSubWindow<sup>9+</sup>
...@@ -6156,19 +6176,20 @@ getSubWindow(): Promise&lt;Array&lt;Window&gt;&gt; ...@@ -6156,19 +6176,20 @@ getSubWindow(): Promise&lt;Array&lt;Window&gt;&gt;
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
let windowClass = null; let windowClass = null;
let promise = windowStage.getSubWindow(); let promise = windowStage.getSubWindow();
promise.then((data)=> { promise.then((data) => {
windowClass = data; windowClass = data;
console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data)); console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err) => {
console.error('Failed to obtain the subwindow. Cause: ' + JSON.stringify(err)); console.error('Failed to obtain the subwindow. Cause: ' + JSON.stringify(err));
}) })
} }
} };
``` ```
### loadContent<sup>9+</sup> ### loadContent<sup>9+</sup>
...@@ -6201,6 +6222,7 @@ loadContent(path: string, storage: LocalStorage, callback: AsyncCallback&lt;void ...@@ -6201,6 +6222,7 @@ loadContent(path: string, storage: LocalStorage, callback: AsyncCallback&lt;void
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
storage : LocalStorage storage : LocalStorage
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
...@@ -6219,7 +6241,7 @@ class myAbility extends Ability { ...@@ -6219,7 +6241,7 @@ class myAbility extends Ability {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
}; };
} }
} };
``` ```
### loadContent<sup>9+</sup> ### loadContent<sup>9+</sup>
...@@ -6258,6 +6280,7 @@ loadContent(path: string, storage?: LocalStorage): Promise&lt;void&gt; ...@@ -6258,6 +6280,7 @@ loadContent(path: string, storage?: LocalStorage): Promise&lt;void&gt;
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
storage : LocalStorage storage : LocalStorage
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
...@@ -6266,16 +6289,16 @@ class myAbility extends Ability { ...@@ -6266,16 +6289,16 @@ class myAbility extends Ability {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
try { try {
let promise = windowStage.loadContent('pages/page2',this.storage); let promise = windowStage.loadContent('pages/page2',this.storage);
promise.then(()=> { promise.then(() => {
console.info('Succeeded in loading the content.'); console.info('Succeeded in loading the content.');
}).catch((err)=>{ }).catch((err) => {
console.error('Failed to load the content. Cause:' + JSON.stringify(err)); console.error('Failed to load the content. Cause:' + JSON.stringify(err));
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
}; };
} }
} };
``` ```
### loadContent<sup>9+</sup> ### loadContent<sup>9+</sup>
...@@ -6308,6 +6331,7 @@ loadContent(path: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -6308,6 +6331,7 @@ loadContent(path: string, callback: AsyncCallback&lt;void&gt;): void
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
...@@ -6323,7 +6347,7 @@ class myAbility extends Ability { ...@@ -6323,7 +6347,7 @@ class myAbility extends Ability {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
}; };
} }
} };
``` ```
### on('windowStageEvent')<sup>9+</sup> ### on('windowStageEvent')<sup>9+</sup>
...@@ -6356,6 +6380,7 @@ on(eventType: 'windowStageEvent', callback: Callback&lt;WindowStageEventType&gt; ...@@ -6356,6 +6380,7 @@ on(eventType: 'windowStageEvent', callback: Callback&lt;WindowStageEventType&gt;
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
...@@ -6369,7 +6394,7 @@ class myAbility extends Ability { ...@@ -6369,7 +6394,7 @@ class myAbility extends Ability {
JSON.stringify(exception)); JSON.stringify(exception));
}; };
} }
} };
``` ```
### off('windowStageEvent')<sup>9+</sup> ### off('windowStageEvent')<sup>9+</sup>
...@@ -6402,6 +6427,7 @@ off(eventType: 'windowStageEvent', callback?: Callback&lt;WindowStageEventType&g ...@@ -6402,6 +6427,7 @@ off(eventType: 'windowStageEvent', callback?: Callback&lt;WindowStageEventType&g
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
...@@ -6412,7 +6438,7 @@ class myAbility extends Ability { ...@@ -6412,7 +6438,7 @@ class myAbility extends Ability {
JSON.stringify(exception)); JSON.stringify(exception));
}; };
} }
} };
``` ```
### disableWindowDecor()<sup>9+</sup> ### disableWindowDecor()<sup>9+</sup>
...@@ -6440,12 +6466,13 @@ disableWindowDecor(): void ...@@ -6440,12 +6466,13 @@ disableWindowDecor(): void
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('disableWindowDecor'); console.log('disableWindowDecor');
windowStage.disableWindowDecor(); windowStage.disableWindowDecor();
} }
} };
``` ```
### setShowOnLockScreen()<sup>9+</sup> ### setShowOnLockScreen()<sup>9+</sup>
...@@ -6479,6 +6506,7 @@ setShowOnLockScreen(showOnLockScreen: boolean): void ...@@ -6479,6 +6506,7 @@ setShowOnLockScreen(showOnLockScreen: boolean): void
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
...@@ -6488,7 +6516,7 @@ class myAbility extends Ability { ...@@ -6488,7 +6516,7 @@ class myAbility extends Ability {
console.error('Failed to show on lockscreen. Cause:' + JSON.stringify(exception)); console.error('Failed to show on lockscreen. Cause:' + JSON.stringify(exception));
}; };
} }
} };
``` ```
## TransitionContext<sup>9+</sup> ## TransitionContext<sup>9+</sup>
...@@ -6525,7 +6553,7 @@ completeTransition(isCompleted: boolean): void ...@@ -6525,7 +6553,7 @@ completeTransition(isCompleted: boolean): void
```js ```js
let controller = windowClass.getTransitionController(); let controller = windowClass.getTransitionController();
controller.animationForShown = (context : window.TransitionContext) => { controller.animationForShown = (context : window.TransitionContext) => {
let toWindow = context.toWindow let toWindow = context.toWindow;
animateTo({ animateTo({
duration: 1000, // 动画时长 duration: 1000, // 动画时长
tempo: 0.5, // 播放速率 tempo: 0.5, // 播放速率
...@@ -6538,11 +6566,11 @@ controller.animationForShown = (context : window.TransitionContext) => { ...@@ -6538,11 +6566,11 @@ controller.animationForShown = (context : window.TransitionContext) => {
x : 100.0, x : 100.0,
y : 0.0, y : 0.0,
z : 0.0 z : 0.0
} };
toWindow.translate(obj); toWindow.translate(obj);
console.info('toWindow translate end'); console.info('toWindow translate end');
} }
) );
try { try {
context.completeTransition(true) context.completeTransition(true)
} catch (exception) { } catch (exception) {
...@@ -6577,7 +6605,7 @@ animationForShown(context: TransitionContext): void ...@@ -6577,7 +6605,7 @@ animationForShown(context: TransitionContext): void
```js ```js
let controller = windowClass.getTransitionController(); let controller = windowClass.getTransitionController();
controller.animationForShown = (context : window.TransitionContext) => { controller.animationForShown = (context : window.TransitionContext) => {
let toWindow = context.toWindow let toWindow = context.toWindow;
animateTo({ animateTo({
duration: 1000, // 动画时长 duration: 1000, // 动画时长
tempo: 0.5, // 播放速率 tempo: 0.5, // 播放速率
...@@ -6593,13 +6621,13 @@ controller.animationForShown = (context : window.TransitionContext) => { ...@@ -6593,13 +6621,13 @@ controller.animationForShown = (context : window.TransitionContext) => {
x : 100.0, x : 100.0,
y : 0.0, y : 0.0,
z : 0.0 z : 0.0
} };
toWindow.translate(obj); toWindow.translate(obj);
console.info('toWindow translate end'); console.info('toWindow translate end');
} }
) );
console.info('complete transition end'); console.info('complete transition end');
} };
``` ```
### animationForHidden<sup>9+</sup> ### animationForHidden<sup>9+</sup>
...@@ -6623,7 +6651,7 @@ animationForHidden(context: TransitionContext): void ...@@ -6623,7 +6651,7 @@ animationForHidden(context: TransitionContext): void
```js ```js
let controller = windowClass.getTransitionController(); let controller = windowClass.getTransitionController();
controller.animationForHidden = (context : window.TransitionContext) => { controller.animationForHidden = (context : window.TransitionContext) => {
let toWindow = context.toWindow let toWindow = context.toWindow;
animateTo({ animateTo({
duration: 1000, // 动画时长 duration: 1000, // 动画时长
tempo: 0.5, // 播放速率 tempo: 0.5, // 播放速率
...@@ -6639,11 +6667,11 @@ controller.animationForHidden = (context : window.TransitionContext) => { ...@@ -6639,11 +6667,11 @@ controller.animationForHidden = (context : window.TransitionContext) => {
x : 100.0, x : 100.0,
y : 0.0, y : 0.0,
z : 0.0 z : 0.0
} };
toWindow.translate(obj); toWindow.translate(obj);
console.info('toWindow translate end'); console.info('toWindow translate end');
} }
) )
console.info('complete transition end'); console.info('complete transition end');
} };
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册