提交 cb4606f0 编写于 作者: Z zhengjiangliang

doc文档示例代码整改

Change-Id: I575b55db46ebae64b56392192773eab0ff73ce08
Signed-off-by: Nzhengjiangliang <zhengjiangliang@huawei.com>
上级 edf2468e
......@@ -94,7 +94,7 @@ try {
displayClass = display.getDefaultDisplaySync();
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
};
}
```
## display.getAllDisplays<sup>9+</sup>
......@@ -204,25 +204,24 @@ hasPrivateWindow(displayId: number): boolean
let displayClass = null;
try {
displayClass = display.getDefaultDisplaySync();
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
return;
};
let ret = undefined;
try {
ret = display.hasPrivateWindow(displayClass.id);
let ret = undefined;
try {
ret = display.hasPrivateWindow(displayClass.id);
} catch (exception) {
console.error('Failed to check has privateWindow or not. Code: ' + JSON.stringify(exception));
}
if (ret == undefined) {
console.log("Failed to check has privateWindow or not.");
}
if (ret) {
console.log("There has privateWindow.");
} else if (!ret) {
console.log("There has no privateWindow.");
}
} catch (exception) {
console.error('Failed to check has privateWindow or not. Code: ' + JSON.stringify(exception));
};
if (ret == undefined) {
console.log("Failed to check has privateWindow or not.");
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}
if (ret) {
console.log("There has privateWindow.");
} else if (!ret) {
console.log("There has no privateWindow.");
};
```
## display.on('add'|'remove'|'change')
......@@ -250,7 +249,7 @@ try {
display.on("add", callback);
} catch (exception) {
console.error('Failed to register callback. Code: ' + JSON.stringify(exception));
};
}
```
## display.off('add'|'remove'|'change')
......@@ -275,7 +274,7 @@ try {
display.off("remove");
} catch (exception) {
console.error('Failed to unregister callback. Code: ' + JSON.stringify(exception));
};
}
```
## display.getDefaultDisplay<sup>(deprecated)</sup>
......@@ -450,17 +449,17 @@ getCutoutInfo(callback: AsyncCallback&lt;CutoutInfo&gt;): void
let displayClass = null;
try {
displayClass = display.getDefaultDisplaySync();
displayClass.getCutoutInfo((err, data) => {
if (err.code) {
console.error('Failed to get cutoutInfo. Code: ' + JSON.stringify(err));
return;
}
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));
};
displayClass.getCutoutInfo((err, data) => {
if (err.code) {
console.error('Failed to get cutoutInfo. Code: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in getting cutoutInfo. data: ' + JSON.stringify(data));
});
}
```
### getCutoutInfo<sup>9+</sup>
getCutoutInfo(): Promise&lt;CutoutInfo&gt;
......@@ -489,12 +488,14 @@ getCutoutInfo(): Promise&lt;CutoutInfo&gt;
let displayClass = null;
try {
displayClass = display.getDefaultDisplaySync();
let promise = displayClass.getCutoutInfo();
promise.then((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));
};
let promise = displayClass.getCutoutInfo();
promise.then((data) => {
console.info('Succeeded in getting cutoutInfo. Data: ' + JSON.stringify(data));
});
}
```
......@@ -339,7 +339,7 @@ try {
});
} catch (exception) {
console.error('Failed to create the window. Cause: ' + JSON.stringify(exception));
};
}
```
## window.createWindow<sup>9+</sup>
......@@ -386,7 +386,7 @@ try {
});
} catch (exception) {
console.error('Failed to create the window. Cause: ' + JSON.stringify(exception));
};
}
```
## window.findWindow<sup>9+</sup>
......@@ -412,11 +412,12 @@ findWindow(name: string): Window
**示例:**
```js
let windowClass = null;
try {
let windowClass = window.findWindow('alertWindow');
windowClass = window.findWindow('alertWindow');
} catch (exception) {
console.error('Failed to find the Window. Cause: ' + JSON.stringify(exception));
};
}
```
## window.getLastWindow<sup>9+</sup>
......@@ -458,7 +459,7 @@ try {
});
} catch (exception) {
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
};
}
```
## window.getLastWindow<sup>9+</sup>
......@@ -504,7 +505,7 @@ try {
});
} catch (exception) {
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
};
}
```
## window.minimizeAll<sup>9+</sup>
......@@ -535,26 +536,25 @@ minimizeAll(id: number, callback: AsyncCallback&lt;void&gt;): void
```js
import display from '@ohos.display'
import window from '@ohos.window'
let displayClass = null;
try {
displayClass = display.getDefaultDisplaySync();
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
return;
};
try {
window.minimizeAll(displayClass.id, (err) => {
if(err.code) {
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in minimizing all windows.');
});
try {
window.minimizeAll(displayClass.id, (err) => {
if(err.code) {
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in minimizing all windows.');
});
} catch (exception) {
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception));
}
} catch (exception) {
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception));
};
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}
```
## window.minimizeAll<sup>9+</sup>
......@@ -590,26 +590,24 @@ minimizeAll(id: number): Promise&lt;void&gt;
```js
import display from '@ohos.display'
import window from '@ohos.window'
let displayClass = null;
try {
displayClass = display.getDefaultDisplaySync();
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
return;
};
try {
let promise = window.minimizeAll(displayClass.id);
promise.then(()=> {
console.info('Succeeded in minimizing all windows.');
}).catch((err)=>{
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
});
try {
let promise = window.minimizeAll(displayClass.id);
promise.then(()=> {
console.info('Succeeded in minimizing all windows.');
}).catch((err)=>{
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception));
}
} catch (exception) {
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception));
};
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}
```
## window.toggleShownStateForAllAppWindows<sup>9+</sup>
......@@ -644,7 +642,7 @@ window.toggleShownStateForAllAppWindows((err) => {
return;
}
console.info('Succeeded in toggling shown state for all app windows.');
})
});
```
## window.toggleShownStateForAllAppWindows<sup>9+</sup>
......@@ -678,7 +676,7 @@ promise.then(()=> {
console.info('Succeeded in toggling shown state for all app windows.');
}).catch((err)=>{
console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err));
})
});
```
## window.setWindowLayoutMode<sup>9+</sup>
......@@ -718,7 +716,7 @@ try {
});
} catch (exception) {
console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception));
};
}
```
## window.setWindowLayoutMode<sup>9+</sup>
......@@ -762,7 +760,7 @@ try {
});
} catch (exception) {
console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception));
};
}
```
## window.on('systemBarTintChange')<sup>8+</sup>
......@@ -791,7 +789,7 @@ try {
});
} catch (exception) {
console.error('Failed to enable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception));
};
}
```
## window.off('systemBarTintChange')<sup>8+</sup>
......@@ -818,7 +816,7 @@ try {
window.off('systemBarTintChange');
} catch (exception) {
console.error('Failed to disable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception));
};
}
```
## window.create<sup>(deprecated)</sup>
......@@ -1110,7 +1108,7 @@ promise.then((data)=> {
console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
})
});
```
## window.getTopWindow<sup>(deprecated)</sup>
......@@ -1180,7 +1178,7 @@ promise.then((data)=> {
console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
})
});
```
## Window
......@@ -1222,7 +1220,7 @@ windowClass.hide((err) => {
return;
}
console.info('Succeeded in hiding the window.');
})
});
```
### hide<sup>7+</sup>
......@@ -1257,7 +1255,7 @@ promise.then(()=> {
console.info('Succeeded in hiding the window.');
}).catch((err)=>{
console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
})
});
```
### hideWithAnimation<sup>9+</sup>
......@@ -1295,7 +1293,7 @@ windowClass.hideWithAnimation((err) => {
return;
}
console.info('Succeeded in hiding the window with animation.');
})
});
```
### hideWithAnimation<sup>9+</sup>
......@@ -1332,7 +1330,7 @@ promise.then(()=> {
console.info('Succeeded in hiding the window with animation.');
}).catch((err)=>{
console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
})
});
```
### showWindow<sup>9+</sup>
......@@ -1437,7 +1435,7 @@ windowClass.showWithAnimation((err) => {
return;
}
console.info('Succeeded in showing the window with animation.');
})
});
```
### showWithAnimation<sup>9+</sup>
......@@ -1474,7 +1472,7 @@ promise.then(()=> {
console.info('Succeeded in showing the window with animation.');
}).catch((err)=>{
console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
})
});
```
### destroyWindow<sup>9+</sup>
......@@ -1509,7 +1507,7 @@ windowClass.destroyWindow((err) => {
return;
}
console.info('Succeeded in destroying the window.');
})
});
```
### destroyWindow<sup>9+</sup>
......@@ -1543,7 +1541,7 @@ promise.then(()=> {
console.info('Succeeded in destroying the window.');
}).catch((err)=>{
console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
})
});
```
### moveWindowTo<sup>9+</sup>
......@@ -1584,7 +1582,7 @@ try {
});
} catch (exception) {
console.error('Failed to move the window. Cause:' + JSON.stringify(exception));
};
}
```
### moveWindowTo<sup>9+</sup>
......@@ -1629,7 +1627,7 @@ try {
});
} catch (exception) {
console.error('Failed to move the window. Cause:' + JSON.stringify(exception));
};
}
```
### resize<sup>9+</sup>
......@@ -1676,7 +1674,7 @@ try {
});
} catch (exception) {
console.error('Failed to change the window size. Cause:' + JSON.stringify(exception));
};
}
```
### resize<sup>9+</sup>
......@@ -1727,7 +1725,7 @@ try {
});
} catch (exception) {
console.error('Failed to change the window size. Cause: ' + JSON.stringify(exception));
};
}
```
### setWindowMode<sup>9+</sup>
......@@ -1770,7 +1768,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception));
};
}
```
### setWindowMode<sup>9+</sup>
......@@ -1809,7 +1807,7 @@ setWindowMode(mode: WindowMode): Promise&lt;void&gt;
```js
let mode = window.WindowMode.FULLSCREEN;
try {
let promise = windowClass.setWindowMode(type);
let promise = windowClass.setWindowMode(mode);
promise.then(()=> {
console.info('Succeeded in setting the window mode.');
}).catch((err)=>{
......@@ -1817,7 +1815,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception));
};
}
```
### getWindowProperties<sup>9+</sup>
......@@ -1849,7 +1847,7 @@ try {
let properties = windowClass.getWindowProperties();
} catch (exception) {
console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(exception));
};
}
```
### getWindowAvoidArea<sup>9+</sup>
......@@ -1888,7 +1886,7 @@ try {
let avoidArea = windowClass.getWindowAvoidArea(type);
} catch (exception) {
console.error('Failed to obtain the area. Cause:' + JSON.stringify(exception));
};
}
```
### setWindowLayoutFullScreen<sup>9+</sup>
......@@ -1929,7 +1927,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception));
};
}
```
### setWindowLayoutFullScreen<sup>9+</sup>
......@@ -1974,7 +1972,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception));
};
}
```
### setWindowSystemBarEnable<sup>9+</sup>
......@@ -2016,7 +2014,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception));
};
}
```
### setWindowSystemBarEnable<sup>9+</sup>
......@@ -2062,7 +2060,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception));
};
}
```
### setWindowSystemBarProperties<sup>9+</sup>
......@@ -2092,7 +2090,7 @@ setWindowSystemBarProperties(systemBarProperties: SystemBarProperties, callback:
**示例:**
```js
let SystemBarProperties={
let SystemBarProperties = {
statusBarColor: '#ff00ff',
navigationBarColor: '#00ff00',
//以下两个属性从API Version8开始支持
......@@ -2109,7 +2107,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception));
};
}
```
### setWindowSystemBarProperties<sup>9+</sup>
......@@ -2144,7 +2142,7 @@ setWindowSystemBarProperties(systemBarProperties: SystemBarProperties): Promise&
**示例:**
```js
let SystemBarProperties={
let SystemBarProperties = {
statusBarColor: '#ff00ff',
navigationBarColor: '#00ff00',
//以下两个属性从API Version8开始支持
......@@ -2160,7 +2158,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception));
};
}
```
### setPreferredOrientation<sup>9+</sup>
......@@ -2200,7 +2198,7 @@ try {
});
} catch (exception) {
console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception));
};
}
```
### setPreferredOrientation<sup>9+</sup>
......@@ -2244,7 +2242,7 @@ try {
});
} catch (exception) {
console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception));
};
}
```
### setUIContent<sup>9+</sup>
......@@ -2284,7 +2282,7 @@ try {
});
} catch (exception) {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
};
}
```
### setUIContent<sup>9+</sup>
......@@ -2328,7 +2326,7 @@ try {
});
} catch (exception) {
console.error('Failed to load the content. Cause: ' + JSON.stringify(exception));
};
}
```
### loadContent<sup>9+</sup>
......@@ -2374,7 +2372,7 @@ try {
});
} catch (exception) {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
};
}
```
### loadContent<sup>9+</sup>
......@@ -2424,7 +2422,7 @@ try {
});
} catch (exception) {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
};
}
```
### isWindowShowing<sup>9+</sup>
......@@ -2457,7 +2455,7 @@ try {
console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
} catch (exception) {
console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(exception));
};
}
```
### on('windowSizeChange')<sup>7+</sup>
......@@ -2484,7 +2482,7 @@ try {
});
} catch (exception) {
console.error('Failed to enable the listener for window size changes. Cause: ' + JSON.stringify(exception));
};
}
```
### off('windowSizeChange')<sup>7+</sup>
......@@ -2509,7 +2507,7 @@ try {
windowClass.off('windowSizeChange');
} catch (exception) {
console.error('Failed to disable the listener for window size changes. Cause: ' + JSON.stringify(exception));
};
}
```
### on('avoidAreaChange')<sup>9+</sup>
......@@ -2537,7 +2535,7 @@ try {
});
} catch (exception) {
console.error('Failed to enable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception));
};
}
```
### off('avoidAreaChange')<sup>9+</sup>
......@@ -2562,7 +2560,7 @@ try {
windowClass.off('avoidAreaChange');
} catch (exception) {
console.error('Failed to disable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception));
};
}
```
### on('keyboardHeightChange')<sup>7+</sup>
......@@ -2589,7 +2587,7 @@ try {
});
} catch (exception) {
console.error('Failed to enable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception));
};
}
```
### off('keyboardHeightChange')<sup>7+</sup>
......@@ -2614,7 +2612,7 @@ try {
windowClass.off('keyboardHeightChange');
} catch (exception) {
console.error('Failed to disable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception));
};
}
```
### on('touchOutside')<sup>9+</sup>
......@@ -2643,7 +2641,7 @@ try {
});
} catch (exception) {
console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
};
}
```
### off('touchOutside')<sup>9+</sup>
......@@ -2670,7 +2668,7 @@ try {
windowClass.off('touchOutside');
} catch (exception) {
console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
};
}
```
### on('screenshot')<sup>9+</sup>
......@@ -2697,7 +2695,7 @@ try {
});
} catch (exception) {
console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
};
}
```
### off('screenshot')<sup>9+</sup>
......@@ -2718,21 +2716,21 @@ off(type: 'screenshot', callback?: Callback&lt;void&gt;): void
**示例:**
```js
let callback = ()=>{
let callback = () => {
console.info('screenshot happened');
};
try {
windowClass.on('screenshot', callback);
} catch (exception) {
console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
};
}
try {
windowClass.off('screenshot', callback);
// 如果通过on开启多个callback进行监听,同时关闭所有监听:
windowClass.off('screenshot');
} catch (exception) {
console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
};
}
```
### on('dialogTargetTouch')<sup>9+</sup>
......@@ -2759,7 +2757,7 @@ try {
});
} catch (exception) {
console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
};
}
```
### off('dialogTargetTouch')<sup>9+</sup>
......@@ -2784,7 +2782,7 @@ try {
windowClass.off('dialogTargetTouch');
} catch (exception) {
console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
};
}
```
### bindDialogTarget<sup>9+</sup>
......@@ -2817,6 +2815,8 @@ bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback&lt;void&gt;, c
**示例:**
```js
import rpc from '@ohos.rpc';
class MyDeathRecipient {
onRemoteDied() {
console.log('server died');
......@@ -2836,6 +2836,7 @@ class TestRemoteObject extends rpc.RemoteObject {
return false;
}
}
let token = new TestRemoteObject('testObject');
try {
windowClass.bindDialogTarget(token, () => {
......@@ -2849,7 +2850,7 @@ try {
});
} catch (exception) {
console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception));
};
}
```
### bindDialogTarget<sup>9+</sup>
......@@ -2887,6 +2888,8 @@ bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback&lt;void&gt;):
**示例:**
```js
import rpc from '@ohos.rpc';
class MyDeathRecipient {
onRemoteDied() {
console.log('server died');
......@@ -2906,6 +2909,7 @@ class TestRemoteObject extends rpc.RemoteObject {
return false;
}
}
let token = new TestRemoteObject('testObject');
try {
let promise = windowClass.bindDialogTarget(token, () => {
......@@ -2918,7 +2922,7 @@ try {
});
} catch (exception) {
console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception));
};
}
```
### isWindowSupportWideGamut<sup>9+</sup>
......@@ -3024,7 +3028,7 @@ try {
});
} catch (exception) {
console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception));
};
}
```
### setWindowColorSpace<sup>9+</sup>
......@@ -3067,7 +3071,7 @@ try {
});
} catch (exception) {
console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception));
};
}
```
### getWindowColorSpace<sup>9+</sup>
......@@ -3128,7 +3132,7 @@ try {
windowClass.setWindowBackgroundColor(color);
} catch (exception) {
console.error('Failed to set the background color. Cause: ' + JSON.stringify(exception));
};
}
```
### setWindowBrightness<sup>9+</sup>
......@@ -3169,7 +3173,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception));
};
}
```
### setWindowBrightness<sup>9+</sup>
......@@ -3214,7 +3218,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception));
};
}
```
### setWindowFocusable<sup>9+</sup>
......@@ -3244,7 +3248,7 @@ setWindowFocusable(isFocusable: boolean, callback: AsyncCallback&lt;void&gt;): v
**示例:**
```js
let isFocusable= true;
let isFocusable = true;
try {
windowClass.setWindowFocusable(isFocusable, (err) => {
if (err.code) {
......@@ -3255,7 +3259,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception));
};
}
```
### setWindowFocusable<sup>9+</sup>
......@@ -3290,7 +3294,7 @@ setWindowFocusable(isFocusable: boolean): Promise&lt;void&gt;
**示例:**
```js
let isFocusable= true;
let isFocusable = true;
try {
let promise = windowClass.setWindowFocusable(isFocusable);
promise.then(()=> {
......@@ -3300,7 +3304,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception));
};
}
```
### setWindowKeepScreenOn<sup>9+</sup>
......@@ -3341,7 +3345,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception));
};
}
```
### setWindowKeepScreenOn<sup>9+</sup>
......@@ -3386,7 +3390,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception));
};
}
```
### setWakeUpScreen()<sup>9+</sup>
......@@ -3422,7 +3426,7 @@ try {
windowClass.setWakeUpScreen(wakeUp);
} catch (exception) {
console.error('Failed to wake up the screen. Cause: ' + JSON.stringify(exception));
};
}
```
### setWindowPrivacyMode<sup>9+</sup>
......@@ -3464,7 +3468,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception));
};
}
```
### setWindowPrivacyMode<sup>9+</sup>
......@@ -3510,7 +3514,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception));
};
}
```
### setSnapshotSkip<sup>9+</sup>
......@@ -3583,7 +3587,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception));
};
}
```
### setWindowTouchable<sup>9+</sup>
......@@ -3628,7 +3632,7 @@ try {
});
} catch (exception) {
console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception));
};
}
```
### setForbidSplitMove<sup>9+</sup>
......@@ -3671,7 +3675,7 @@ try {
});
} catch (exception) {
console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception));
};
}
```
### setForbidSplitMove<sup>9+</sup>
......@@ -3718,7 +3722,7 @@ try {
});
} catch (exception) {
console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception));
};
}
```
### snapshot<sup>9+</sup>
......@@ -3822,7 +3826,7 @@ try {
windowClass.opacity(0.5);
} catch (exception) {
console.error('Failed to opacity. Cause: ' + JSON.stringify(exception));
};
}
```
### scale<sup>9+</sup>
......@@ -3863,7 +3867,7 @@ try {
windowClass.scale(obj);
} catch (exception) {
console.error('Failed to scale. Cause: ' + JSON.stringify(exception));
};
}
```
### rotate<sup>9+</sup>
......@@ -3905,7 +3909,7 @@ try {
windowClass.rotate(obj);
} catch (exception) {
console.error('Failed to rotate. Cause: ' + JSON.stringify(exception));
};
}
```
### translate<sup>9+</sup>
......@@ -3945,7 +3949,7 @@ try {
windowClass.translate(obj);
} catch (exception) {
console.error('Failed to translate. Cause: ' + JSON.stringify(exception));
};
}
```
### getTransitionController<sup>9+</sup>
......@@ -3998,16 +4002,16 @@ controller.animationForHidden = (context : window.TransitionContext) => {
toWindow.translate(obj); // 设置动画过程中的属性转换
console.info('toWindow translate end');
}
)
);
console.info('complete transition end');
}
};
windowClass.hideWithAnimation((err, data) => {
if (err.code) {
console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data));
})
});
```
### setBlur<sup>9+</sup>
......@@ -4042,7 +4046,7 @@ try {
windowClass.setBlur(4.0);
} catch (exception) {
console.error('Failed to set blur. Cause: ' + JSON.stringify(exception));
};
}
```
### setBackdropBlur<sup>9+</sup>
......@@ -4077,7 +4081,7 @@ try {
windowClass.setBackdropBlur(4.0);
} catch (exception) {
console.error('Failed to set backdrop blur. Cause: ' + JSON.stringify(exception));
};
}
```
### setBackdropBlurStyle<sup>9+</sup>
......@@ -4112,7 +4116,7 @@ try {
windowClass.setBackdropBlurStyle(window.BlurStyle.THIN);
} catch (exception) {
console.error('Failed to set backdrop blur style. Cause: ' + JSON.stringify(exception));
};
}
```
### setShadow<sup>9+</sup>
......@@ -4150,7 +4154,7 @@ try {
windowClass.setShadow(4.0, '#FF00FF00', 2, 3);
} catch (exception) {
console.error('Failed to set shadow. Cause: ' + JSON.stringify(exception));
};
}
```
### setCornerRadius<sup>9+</sup>
......@@ -4185,7 +4189,7 @@ try {
windowClass.setCornerRadius(4.0);
} catch (exception) {
console.error('Failed to set corner radius. Cause: ' + JSON.stringify(exception));
};
}
```
### show<sup>(deprecated)</sup>
......@@ -4215,7 +4219,7 @@ windowClass.show((err) => {
return;
}
console.info('Succeeded in showing the window.');
})
});
```
### show<sup>(deprecated)</sup>
......@@ -4244,7 +4248,7 @@ promise.then(()=> {
console.info('Succeeded in showing the window.');
}).catch((err)=>{
console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
})
});
```
### destroy<sup>(deprecated)</sup>
......@@ -4274,7 +4278,7 @@ windowClass.destroy((err) => {
return;
}
console.info('Succeeded in destroying the window.');
})
});
```
### destroy<sup>(deprecated)</sup>
......@@ -4303,7 +4307,7 @@ promise.then(()=> {
console.info('Succeeded in destroying the window.');
}).catch((err)=>{
console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
})
});
```
### moveTo<sup>(deprecated)</sup>
......@@ -4335,7 +4339,6 @@ windowClass.moveTo(300, 300, (err)=>{
return;
}
console.info('Succeeded in moving the window.');
});
```
......@@ -4372,7 +4375,7 @@ promise.then(()=> {
console.info('Succeeded in moving the window.');
}).catch((err)=>{
console.error('Failed to move the window. Cause: ' + JSON.stringify(err));
})
});
```
### resetSize<sup>(deprecated)</sup>
......@@ -5144,7 +5147,7 @@ windowClass.isSupportWideGamut((err, data) => {
return;
}
console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data));
})
});
```
### isSupportWideGamut<sup>(deprecated)</sup>
......@@ -5204,7 +5207,7 @@ windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err) => {
return;
}
console.info('Succeeded in setting window colorspace.');
})
});
```
### setColorSpace<sup>(deprecated)</sup>
......@@ -5269,7 +5272,7 @@ windowClass.getColorSpace((err, data) => {
return;
}
console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data));
})
});
```
### getColorSpace<sup>(deprecated)</sup>
......@@ -5667,7 +5670,7 @@ windowClass.setOutsideTouchable(true, (err) => {
return;
}
console.info('Succeeded in setting the area to be touchable.');
})
});
```
### setOutsideTouchable<sup>(deprecated)</sup>
......@@ -5734,7 +5737,6 @@ windowClass.setPrivacyMode(isPrivacyMode, (err) => {
return;
}
console.info('Succeeded in setting the window to privacy mode.');
});
```
......@@ -5803,7 +5805,6 @@ windowClass.setTouchable(isTouchable, (err) => {
return;
}
console.info('Succeeded in setting the window to be touchable.');
});
```
......@@ -5893,6 +5894,7 @@ getMainWindow(callback: AsyncCallback&lt;Window&gt;): void
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
......@@ -5906,7 +5908,7 @@ class myAbility extends Ability {
console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
});
}
}
};
```
### getMainWindow<sup>9+</sup>
......@@ -5938,19 +5940,20 @@ getMainWindow(): Promise&lt;Window&gt;
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
let windowClass = null;
let promise = windowStage.getMainWindow();
promise.then((data)=> {
promise.then((data) => {
windowClass = 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));
});
}
}
};
```
### getMainWindowSync<sup>9+</sup>
......@@ -5982,6 +5985,7 @@ getMainWindowSync(): Window
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
......@@ -5991,7 +5995,7 @@ class myAbility extends Ability {
console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(exception));
};
}
}
};
```
### createSubWindow<sup>9+</sup>
......@@ -6024,6 +6028,7 @@ createSubWindow(name: string, callback: AsyncCallback&lt;Window&gt;): void
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
......@@ -6042,7 +6047,7 @@ class myAbility extends Ability {
console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception));
};
}
}
};
```
### createSubWindow<sup>9+</sup>
......@@ -6079,23 +6084,24 @@ createSubWindow(name: string): Promise&lt;Window&gt;
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
let windowClass = null;
try {
let promise = windowStage.createSubWindow('mySubWindow');
promise.then((data)=> {
promise.then((data) => {
windowClass = 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));
});
} catch (exception) {
console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception));
};
}
}
};
```
### getSubWindow<sup>9+</sup>
......@@ -6126,6 +6132,7 @@ getSubWindow(callback: AsyncCallback&lt;Array&lt;Window&gt;&gt;): void
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
......@@ -6139,7 +6146,7 @@ class myAbility extends Ability {
console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data));
});
}
}
};
```
### getSubWindow<sup>9+</sup>
......@@ -6169,19 +6176,20 @@ getSubWindow(): Promise&lt;Array&lt;Window&gt;&gt;
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
let windowClass = null;
let promise = windowStage.getSubWindow();
promise.then((data)=> {
promise.then((data) => {
windowClass = 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));
})
}
}
};
```
### loadContent<sup>9+</sup>
......@@ -6214,6 +6222,7 @@ loadContent(path: string, storage: LocalStorage, callback: AsyncCallback&lt;void
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
storage : LocalStorage
onWindowStageCreate(windowStage) {
......@@ -6232,7 +6241,7 @@ class myAbility extends Ability {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
};
}
}
};
```
### loadContent<sup>9+</sup>
......@@ -6271,6 +6280,7 @@ loadContent(path: string, storage?: LocalStorage): Promise&lt;void&gt;
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
storage : LocalStorage
onWindowStageCreate(windowStage) {
......@@ -6279,16 +6289,16 @@ class myAbility extends Ability {
console.log('onWindowStageCreate');
try {
let promise = windowStage.loadContent('pages/page2',this.storage);
promise.then(()=> {
promise.then(() => {
console.info('Succeeded in loading the content.');
}).catch((err)=>{
}).catch((err) => {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
};
}
}
};
```
### loadContent<sup>9+</sup>
......@@ -6321,6 +6331,7 @@ loadContent(path: string, callback: AsyncCallback&lt;void&gt;): void
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
......@@ -6336,7 +6347,7 @@ class myAbility extends Ability {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
};
}
}
};
```
### on('windowStageEvent')<sup>9+</sup>
......@@ -6369,6 +6380,7 @@ on(eventType: 'windowStageEvent', callback: Callback&lt;WindowStageEventType&gt;
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
......@@ -6382,7 +6394,7 @@ class myAbility extends Ability {
JSON.stringify(exception));
};
}
}
};
```
### off('windowStageEvent')<sup>9+</sup>
......@@ -6415,6 +6427,7 @@ off(eventType: 'windowStageEvent', callback?: Callback&lt;WindowStageEventType&g
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
......@@ -6425,7 +6438,7 @@ class myAbility extends Ability {
JSON.stringify(exception));
};
}
}
};
```
### disableWindowDecor()<sup>9+</sup>
......@@ -6453,12 +6466,13 @@ disableWindowDecor(): void
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('disableWindowDecor');
windowStage.disableWindowDecor();
}
}
};
```
### setShowOnLockScreen()<sup>9+</sup>
......@@ -6492,6 +6506,7 @@ setShowOnLockScreen(showOnLockScreen: boolean): void
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
......@@ -6501,7 +6516,7 @@ class myAbility extends Ability {
console.error('Failed to show on lockscreen. Cause:' + JSON.stringify(exception));
};
}
}
};
```
## TransitionContext<sup>9+</sup>
......@@ -6555,7 +6570,7 @@ controller.animationForShown = (context : window.TransitionContext) => {
toWindow.translate(obj);
console.info('toWindow translate end');
}
)
);
try {
context.completeTransition(true)
} catch (exception) {
......@@ -6610,9 +6625,9 @@ controller.animationForShown = (context : window.TransitionContext) => {
toWindow.translate(obj);
console.info('toWindow translate end');
}
)
);
console.info('complete transition end');
}
};
```
### animationForHidden<sup>9+</sup>
......@@ -6658,5 +6673,5 @@ controller.animationForHidden = (context : window.TransitionContext) => {
}
)
console.info('complete transition end');
}
};
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册