提交 9b3bd10f 编写于 作者: G Gloria

Update docs against 14315+14779+14781+14866+14504

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 4083258f
......@@ -21,7 +21,7 @@ The table below lists the common APIs used for application window development. F
| Instance| API| Description|
| -------- | -------- | -------- |
| Window static method| createWindow(config: Configuration, callback: AsyncCallback\<Window>): void | Creates a subwindow.<br>**config** specifies the parameters used for creating the window.|
| Window static method| findWindow(id: string, callback: AsyncCallback&lt;Window&gt;): void | Finds a window based on the ID.|
| Window static method| findWindow(name: string): Window | Finds a window based on the name.|
| Window | SetUIContent(path: string, callback: AsyncCallback&lt;void&gt;): void | Loads the page content to this window.|
| Window | moveWindowTo(x: number, y: number, callback: AsyncCallback&lt;void&gt;): void | Moves this window.|
| Window | setWindowBackgroundColor(color: string, callback: AsyncCallback&lt;void&gt;): void | Sets the background color for this window.|
......@@ -62,14 +62,11 @@ You can create a subwindow, such as a dialog box, and set its properties.
windowClass = data;
});
// Method 2: Find a subwindow.
window.findWindow("subWindow", (err, data) => {
if (err.code) {
console.error('Failed to find the subWindow. Cause: ' + JSON.stringify(err));
return;
try {
windowClass = window.findWindow('subWindow');
} catch (exception) {
console.error('Failed to find the Window. Cause: ' + JSON.stringify(exception));
}
console.info('Succeeded in finding subWindow. Data: ' + JSON.stringify(data));
windowClass = data;
});
```
2. Set the properties of the subwindow.
......@@ -154,7 +151,7 @@ To create a better video watching and gaming experience, you can use the immersi
let mainWindowClass = null;
// Obtain the main window.
window.getLastWindow((err, data) => {
window.getLastWindow(this.context,(err, data) => {
if (err.code) {
console.error('Failed to get the subWindow. Cause: ' + JSON.stringify(err));
return;
......@@ -164,7 +161,7 @@ To create a better video watching and gaming experience, you can use the immersi
});
```
2. Implement the immersive effect. You can use any of the following methods:
2. Implement the immersive effect. You can use either of the following methods:
- Method 1: Call **setWindowSystemBarEnable** to hide the navigation bar and status bar.
- Method 2: Call **setWindowLayoutFullScreen** to enable the full-screen mode for the main window layout. Call **setSystemProperties** to set the opacity, background color, text color, and highlighted icon of the navigation bar and status bar to ensure that their display effect is consistent with that of the main window.
......
......@@ -49,7 +49,7 @@ The table below lists the common APIs used for application window development. F
## Setting the Main Window of an Application
In the stage model, the main window of an application is created and maintained by an **Ability** instance. In the **onWindowStageCreate** callback of the **Ability** instance, use **WindowStage** to obtain the main window of the application and set its properties.
In the stage model, the main window of an application is created and maintained by a **UIAbility** instance. In the **onWindowStageCreate** callback of the **UIAbility** instance, use **WindowStage** to obtain the main window of the application and set its properties. You can also set the properties (for example, **maxWindowWidth**) in the [module.json5 file](../quick-start/module-configuration-file.md#abilities).
### How to Develop
......@@ -66,10 +66,10 @@ In the stage model, the main window of an application is created and maintained
Call **loadContent** to load the page content to the main window.
```ts
import Ability from '@ohos.application.Ability'
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
class MainAbility extends Ability {
export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) {
// 1. Obtain the main window of the application.
let windowClass = null;
......@@ -99,8 +99,8 @@ class MainAbility extends Ability {
console.info('Succeeded in loading the content.');
});
}
};
```
};
```
## Setting a Subwindow of an Application
......@@ -127,11 +127,11 @@ You can create an application subwindow, such as a dialog box, and set its prope
When the subwindow is no longer needed, you can call **destroyWindow** to destroy it.
```ts
import Ability from '@ohos.application.Ability'
import UIAbility from '@ohos.app.ability.UIAbility';
let windowStage_ = null;
let sub_windowClass = null;
class MainAbility extends Ability {
export default class EntryAbility extends UIAbility {
showSubWindow() {
// 1. Create a subwindow.
windowStage_.createSubWindow("mySubWindow", (err, data) => {
......@@ -211,7 +211,7 @@ To create a better video watching and gaming experience, you can use the immersi
Call **getMainWindow** to obtain the main window of the application.
2. Implement the immersive effect. You can use any of the following methods:
2. Implement the immersive effect. You can use either of the following methods:
- Method 1: Call **setWindowSystemBarEnable** to hide the navigation bar and status bar.
- Method 2: Call **setWindowLayoutFullScreen** to enable the full-screen mode for the main window layout. Call **setWindowSystemBarProperties** to set the opacity, background color, text color, and highlighted icon of the navigation bar and status bar to ensure that their display effect is consistent with that of the main window.
......@@ -220,9 +220,9 @@ To create a better video watching and gaming experience, you can use the immersi
Call **loadContent** to load the content to the immersive window.
```ts
import Ability from '@ohos.application.Ability'
import UIAbility from '@ohos.app.ability.UIAbility';
class MainAbility extends Ability {
export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) {
// 1. Obtain the main window of the application.
let windowClass = null;
......@@ -282,7 +282,7 @@ To create a better video watching and gaming experience, you can use the immersi
## Setting a Floating Window
A floating window is created based on an existing task. It is always displayed in the foreground, even if the task used for creating the floating window is switched to the background. You can create a floating window and set its properties.
A floating window is created based on an existing task. It is always displayed in the foreground, even if the task used for creating the floating window is switched to the background. Generally, the floating window is above all application windows. You can create a floating window and set its properties.
### How to Develop
......@@ -303,7 +303,7 @@ A floating window is created based on an existing task. It is always displayed i
"name" : "ohos.permission.SYSTEM_FLOAT_WINDOW",
"usedScene": {
"abilities": [
"MainAbility"
"EntryAbility"
],
"when":"inuse"
}
......@@ -330,11 +330,11 @@ A floating window is created based on an existing task. It is always displayed i
When the floating window is no longer needed, you can call **destroyWindow** to destroy it.
```ts
import Ability from '@ohos.application.Ability'
import ExtensionContext from '@ohos.application.ServiceExtensionAbility';
import UIAbility from '@ohos.app.ability.UIAbility';
import ExtensionContext from '@ohos.app.ability.ServiceExtensionAbility';
import window from '@ohos.window';
class MainAbility extends Ability {
export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) {
// 2. Create a floating window.
let windowClass = null;
......
......@@ -58,12 +58,11 @@ This section uses the volume bar as an example to describe how to develop a syst
When the volume bar window is no longer needed, you can call **hide** or **destroyWindow** to hide or destroy it.
```ts
import ExtensionContext from '@ohos.application.ServiceExtensionAbility';
import ExtensionContext from '@ohos.app.ability.ServiceExtensionAbility';
import window from '@ohos.window';
export default class ServiceExtensionAbility1 extends ExtensionContext {
onCreate(want) {
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
// 1. Create a volume bar window.
let windowClass = null;
......@@ -151,7 +150,6 @@ import window from '@ohos.window';
export default class ServiceExtensionAbility1 extends ExtensionContext {
onCreate(want) {
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
// Create a volume bar window.
let windowClass = null;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册