dismissSoftInput implemented

This commit is contained in:
Vladimir Enchev
2015-10-19 14:55:06 +03:00
parent 66a834ce10
commit 343265c571
7 changed files with 68 additions and 10 deletions

View File

@@ -2,13 +2,13 @@
import textBase = require("ui/text-base");
import dependencyObservable = require("ui/core/dependency-observable");
import enums = require("ui/enums");
import utils = require("utils/utils");
export class EditableTextBase extends common.EditableTextBase {
private _android: android.widget.EditText;
/* tslint:disable */
private _dirtyTextAccumulator: string;
/* tslint:enable */
private _imm: android.view.inputmethod.InputMethodManager;
constructor(options?: textBase.Options) {
super(options);
@@ -18,9 +18,7 @@ export class EditableTextBase extends common.EditableTextBase {
return this._android;
}
public _createUI() {
this._imm = <android.view.inputmethod.InputMethodManager>this._context.getSystemService(android.content.Context.INPUT_METHOD_SERVICE);
public _createUI() {
this._android = new android.widget.EditText(this._context);
this._configureEditText();
this.android.setTag(this.android.getKeyListener());
@@ -103,23 +101,20 @@ export class EditableTextBase extends common.EditableTextBase {
}
public _onDetached(force?: boolean) {
this._imm = undefined;
this._android = undefined;
super._onDetached(force);
}
public dismissSoftInput() {
if (this._imm) {
this._imm.hideSoftInputFromWindow(this._android.getWindowToken(), 0);
}
utils.ad.dismissSoftInput(this._nativeView);
}
public focus(): boolean {
var result = super.focus();
if (result && this._nativeView) {
this._imm.showSoftInput(this._nativeView, android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT);
if (result) {
utils.ad.showSoftInput(this._nativeView);
}
return result;

View File

@@ -50,4 +50,7 @@ export class SearchBar extends view.View implements definition.SearchBar {
value instanceof color.Color ? value : new color.Color(<any>value));
}
public dismissSoftInput() {
//
}
}

View File

@@ -96,6 +96,20 @@ global.moduleMerge(common, exports);
export class SearchBar extends common.SearchBar {
private _android: android.widget.SearchView;
public dismissSoftInput() {
utils.ad.dismissSoftInput(this._nativeView);
}
public focus(): boolean {
var result = super.focus();
if (result) {
utils.ad.showSoftInput(this._nativeView);
}
return result;
}
public _createUI() {
this._android = new android.widget.SearchView(this._context);

View File

@@ -78,5 +78,10 @@ declare module "ui/search-bar" {
* Raised when a search bar search is closed.
*/
on(event: "close", callback: (args: observable.EventData) => void, thisArg?: any);
/**
* Hides the soft input method, ususally a soft keyboard.
*/
dismissSoftInput(): void;
}
}

View File

@@ -115,6 +115,10 @@ export class SearchBar extends common.SearchBar {
super.onUnloaded();
}
public dismissSoftInput() {
(<UIResponder>this.ios).resignFirstResponder();
}
get ios(): UISearchBar {
return this._ios;
}