提交 df7c3b74 编写于 作者: H Hollokin

【输入法框架】示例代码修改

Signed-off-by: NHollokin <taoyuxin2@huawei.com>
上级 c564b9a7
...@@ -93,7 +93,7 @@ getSetting(): InputMethodSetting ...@@ -93,7 +93,7 @@ getSetting(): InputMethodSetting
**示例:** **示例:**
```js ```js
let InputMethodSetting = inputMethod.getSetting(); let inputMethodSetting = inputMethod.getSetting();
``` ```
## inputMethod.switchInputMethod<sup>9+</sup> ## inputMethod.switchInputMethod<sup>9+</sup>
...@@ -239,7 +239,7 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb ...@@ -239,7 +239,7 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb
```js ```js
let inputMethodSubtype = { let inputMethodSubtype = {
id: "com.example.kikainput", id: "com.example.kikakeyboard",
label: "ServiceExtAbility", label: "ServiceExtAbility",
name: "", name: "",
mode: "upper", mode: "upper",
...@@ -301,7 +301,7 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise&lt;boolean& ...@@ -301,7 +301,7 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise&lt;boolean&
```js ```js
let inputMethodSubtype = { let inputMethodSubtype = {
id: "com.example.kikainput", id: "com.example.kikakeyboard",
label: "ServiceExtAbility", label: "ServiceExtAbility",
name: "", name: "",
mode: "upper", mode: "upper",
...@@ -382,7 +382,7 @@ let inputMethodProperty = { ...@@ -382,7 +382,7 @@ let inputMethodProperty = {
extra: {} extra: {}
} }
let inputMethodSubProperty = { let inputMethodSubProperty = {
id: "com.example.kikainput", id: "com.example.kikakeyboard",
label: "ServiceExtAbility", label: "ServiceExtAbility",
name: "", name: "",
mode: "upper", mode: "upper",
...@@ -445,19 +445,23 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp ...@@ -445,19 +445,23 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
```js ```js
let inputMethodProperty = { let inputMethodProperty = {
name: "com.example.kikakeyboard", packageName: "com.example.kikakeyboard",
id: "ServiceExtAbility" methodId: "ServiceExtAbility",
extra: {}
} }
let inputMethodSubProperty = { let inputMethodSubProperty = {
id: "com.example.kikakeyboard", id: "com.example.kikakeyboard",
name: "",
locale: "",
label: "ServiceExtAbility", label: "ServiceExtAbility",
language: "", name: "",
extra : {} mode: "upper",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
} }
try { try {
inputMethod.switchCurrentInputMethodAndSubtype(property, subType).then((result) => { inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, inputMethodSubProperty).then((result) => {
if (result) { if (result) {
console.info('Success to switchCurrentInputMethodAndSubtype.'); console.info('Success to switchCurrentInputMethodAndSubtype.');
} else { } else {
...@@ -514,7 +518,7 @@ getInputMethodSetting(): InputMethodSetting ...@@ -514,7 +518,7 @@ getInputMethodSetting(): InputMethodSetting
**示例:** **示例:**
```js ```js
let InputMethodSetting = inputMethod.getInputMethodSetting(); let inputMethodSetting = inputMethod.getInputMethodSetting();
``` ```
## InputMethodController ## InputMethodController
...@@ -837,10 +841,8 @@ on(type: 'imeChange', callback: (inputMethodProperty: InputMethodProperty, input ...@@ -837,10 +841,8 @@ on(type: 'imeChange', callback: (inputMethodProperty: InputMethodProperty, input
**示例:** **示例:**
```js ```js
let InputMethodSetting = inputMethod.getSetting(); inputMethodSetting.on('imeChange', (inputMethodProperty, inputMethodSubtype) => {
InputMethodSetting.on('imeChange', (inputMethodProperty, inputMethodSubtype) => { console.info('Succeeded in subscribing imeChange: inputMethodProperty: ' + JSON.stringify(inputMethodProperty) + " , inputMethodSubtype: " + JSON.stringify(inputMethodSubtype));
InputMethodProperty = inputMethodProperty;
InputMethodSubtype = inputMethodSubtype;
}); });
``` ```
...@@ -862,8 +864,7 @@ off(type: 'imeChange', callback?: (inputMethodProperty: InputMethodProperty, inp ...@@ -862,8 +864,7 @@ off(type: 'imeChange', callback?: (inputMethodProperty: InputMethodProperty, inp
**示例:** **示例:**
```js ```js
let InputMethodSetting = inputMethod.getSetting(); inputMethodSetting.off('imeChange');
InputMethodSetting.off('imeChange');
``` ```
### listInputMethodSubtype<sup>9+</sup> ### listInputMethodSubtype<sup>9+</sup>
...@@ -899,7 +900,7 @@ let inputMethodProperty = { ...@@ -899,7 +900,7 @@ let inputMethodProperty = {
extra:{} extra:{}
} }
try { try {
InputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err,data) => { inputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err,data) => {
if (err) { if (err) {
console.error('listInputMethodSubtype failed: ' + JSON.stringify(err)); console.error('listInputMethodSubtype failed: ' + JSON.stringify(err));
return; return;
...@@ -949,7 +950,7 @@ let inputMethodProperty = { ...@@ -949,7 +950,7 @@ let inputMethodProperty = {
extra:{} extra:{}
} }
try { try {
InputMethodSetting.listInputMethodSubtype(inputMethodProperty).then((data) => { inputMethodSetting.listInputMethodSubtype(inputMethodProperty).then((data) => {
console.info('listInputMethodSubtype success'); console.info('listInputMethodSubtype success');
}).catch((err) => { }).catch((err) => {
console.error('listInputMethodSubtype err: ' + JSON.stringify(err)); console.error('listInputMethodSubtype err: ' + JSON.stringify(err));
...@@ -986,7 +987,7 @@ listCurrentInputMethodSubtype(callback: AsyncCallback&lt;Array&lt;InputMethodSub ...@@ -986,7 +987,7 @@ listCurrentInputMethodSubtype(callback: AsyncCallback&lt;Array&lt;InputMethodSub
```js ```js
try { try {
InputMethodSetting.listCurrentInputMethodSubtype((err, data) => { inputMethodSetting.listCurrentInputMethodSubtype((err, data) => {
if (err) { if (err) {
console.error('listCurrentInputMethodSubtype failed: ' + JSON.stringify(err)); console.error('listCurrentInputMethodSubtype failed: ' + JSON.stringify(err));
return; return;
...@@ -1025,7 +1026,7 @@ listCurrentInputMethodSubtype(): Promise&lt;Array&lt;InputMethodSubtype&gt;&gt; ...@@ -1025,7 +1026,7 @@ listCurrentInputMethodSubtype(): Promise&lt;Array&lt;InputMethodSubtype&gt;&gt;
```js ```js
try { try {
InputMethodSetting.listCurrentInputMethodSubtype().then((data) => { inputMethodSetting.listCurrentInputMethodSubtype().then((data) => {
console.info('listCurrentInputMethodSubtype success'); console.info('listCurrentInputMethodSubtype success');
}).catch((err) => { }).catch((err) => {
console.error('listCurrentInputMethodSubtype err: ' + err); console.error('listCurrentInputMethodSubtype err: ' + err);
...@@ -1063,7 +1064,7 @@ getInputMethods(enable: boolean, callback: AsyncCallback&lt;Array&lt;InputMethod ...@@ -1063,7 +1064,7 @@ getInputMethods(enable: boolean, callback: AsyncCallback&lt;Array&lt;InputMethod
```js ```js
try { try {
InputMethodSetting.getInputMethods(true, (err,data) => { inputMethodSetting.getInputMethods(true, (err,data) => {
if (err) { if (err) {
console.error('getInputMethods failed: ' + JSON.stringify(err)); console.error('getInputMethods failed: ' + JSON.stringify(err));
return; return;
...@@ -1108,7 +1109,7 @@ getInputMethods(enable: boolean): Promise&lt;Array&lt;InputMethodProperty&gt;&gt ...@@ -1108,7 +1109,7 @@ getInputMethods(enable: boolean): Promise&lt;Array&lt;InputMethodProperty&gt;&gt
```js ```js
try { try {
InputMethodSetting.getInputMethods(true).then((data) => { inputMethodSetting.getInputMethods(true).then((data) => {
console.info('getInputMethods success'); console.info('getInputMethods success');
}).catch((err) => { }).catch((err) => {
console.error('getInputMethods err: ' + JSON.stringify(err)); console.error('getInputMethods err: ' + JSON.stringify(err));
...@@ -1146,7 +1147,7 @@ showOptionalInputMethods(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1146,7 +1147,7 @@ showOptionalInputMethods(callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
try { try {
InputMethodSetting.showOptionalInputMethods((err, data) => { inputMethodSetting.showOptionalInputMethods((err, data) => {
if (err) { if (err) {
console.error('showOptionalInputMethods failed: ' + JSON.stringify(err)); console.error('showOptionalInputMethods failed: ' + JSON.stringify(err));
return; return;
...@@ -1185,7 +1186,7 @@ showOptionalInputMethods(): Promise&lt;boolean&gt; ...@@ -1185,7 +1186,7 @@ showOptionalInputMethods(): Promise&lt;boolean&gt;
**示例:** **示例:**
```js ```js
InputMethodSetting.showOptionalInputMethods().then((data) => { inputMethodSetting.showOptionalInputMethods().then((data) => {
console.info('displayOptionalInputMethod success.'); console.info('displayOptionalInputMethod success.');
}).catch((err) => { }).catch((err) => {
console.error('displayOptionalInputMethod err: ' + err); console.error('displayOptionalInputMethod err: ' + err);
...@@ -1213,7 +1214,7 @@ listInputMethod(callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;) ...@@ -1213,7 +1214,7 @@ listInputMethod(callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;)
**示例:** **示例:**
```js ```js
InputMethodSetting.listInputMethod((err,data) => { inputMethodSetting.listInputMethod((err,data) => {
if (err) { if (err) {
console.error('listInputMethod failed because: ' + JSON.stringify(err)); console.error('listInputMethod failed because: ' + JSON.stringify(err));
return; return;
...@@ -1243,7 +1244,7 @@ listInputMethod(): Promise&lt;Array&lt;InputMethodProperty&gt;&gt; ...@@ -1243,7 +1244,7 @@ listInputMethod(): Promise&lt;Array&lt;InputMethodProperty&gt;&gt;
**示例:** **示例:**
```js ```js
InputMethodSetting.listInputMethod().then((data) => { inputMethodSetting.listInputMethod().then((data) => {
console.info('listInputMethod success'); console.info('listInputMethod success');
}).catch((err) => { }).catch((err) => {
console.error('listInputMethod err: ' + JSON.stringify(err)); console.error('listInputMethod err: ' + JSON.stringify(err));
...@@ -1271,7 +1272,7 @@ displayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void ...@@ -1271,7 +1272,7 @@ displayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
```js ```js
InputMethodSetting.displayOptionalInputMethod((err) => { inputMethodSetting.displayOptionalInputMethod((err) => {
if (err) { if (err) {
console.error('displayOptionalInputMethod failed because: ' + JSON.stringify(err)); console.error('displayOptionalInputMethod failed because: ' + JSON.stringify(err));
return; return;
...@@ -1301,7 +1302,7 @@ displayOptionalInputMethod(): Promise&lt;void&gt; ...@@ -1301,7 +1302,7 @@ displayOptionalInputMethod(): Promise&lt;void&gt;
**示例:** **示例:**
```js ```js
InputMethodSetting.displayOptionalInputMethod().then(() => { inputMethodSetting.displayOptionalInputMethod().then(() => {
console.info('displayOptionalInputMethod success'); console.info('displayOptionalInputMethod success');
}).catch((err) => { }).catch((err) => {
console.error('displayOptionalInputMethod err: ' + err); console.error('displayOptionalInputMethod err: ' + err);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册