mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
event check
This commit is contained in:
@ -20,18 +20,18 @@ export class EditableTextBase extends common.EditableTextBase {
|
|||||||
return this._android;
|
return this._android;
|
||||||
}
|
}
|
||||||
|
|
||||||
public _createUI() {
|
public _createUI() {
|
||||||
this._android = new android.widget.EditText(this._context);
|
this._android = new android.widget.EditText(this._context);
|
||||||
this._configureEditText();
|
this._configureEditText();
|
||||||
this.android.setTag(this.android.getKeyListener());
|
this.android.setTag(this.android.getKeyListener());
|
||||||
|
|
||||||
var that = new WeakRef(this);
|
var that = new WeakRef(this);
|
||||||
|
|
||||||
this._textWatcher = new android.text.TextWatcher({
|
this._textWatcher = new android.text.TextWatcher({
|
||||||
beforeTextChanged: function (text: string, start: number, count: number, after: number) {
|
beforeTextChanged: function(text: string, start: number, count: number, after: number) {
|
||||||
//
|
//
|
||||||
},
|
},
|
||||||
onTextChanged: function (text: string, start: number, before: number, count: number) {
|
onTextChanged: function(text: string, start: number, before: number, count: number) {
|
||||||
var owner = that.get();
|
var owner = that.get();
|
||||||
if (!owner) {
|
if (!owner) {
|
||||||
return;
|
return;
|
||||||
@ -42,7 +42,7 @@ export class EditableTextBase extends common.EditableTextBase {
|
|||||||
owner.android.addTextChangedListener(owner._textWatcher);
|
owner.android.addTextChangedListener(owner._textWatcher);
|
||||||
owner.android.setSelection(selectionStart);
|
owner.android.setSelection(selectionStart);
|
||||||
},
|
},
|
||||||
afterTextChanged: function (editable: android.text.IEditable) {
|
afterTextChanged: function(editable: android.text.IEditable) {
|
||||||
var owner = that.get();
|
var owner = that.get();
|
||||||
if (!owner) {
|
if (!owner) {
|
||||||
return;
|
return;
|
||||||
@ -63,7 +63,7 @@ export class EditableTextBase extends common.EditableTextBase {
|
|||||||
this._android.addTextChangedListener(this._textWatcher);
|
this._android.addTextChangedListener(this._textWatcher);
|
||||||
|
|
||||||
var focusChangeListener = new android.view.View.OnFocusChangeListener({
|
var focusChangeListener = new android.view.View.OnFocusChangeListener({
|
||||||
onFocusChange: function (view: android.view.View, hasFocus: boolean) {
|
onFocusChange: function(view: android.view.View, hasFocus: boolean) {
|
||||||
var owner = that.get();
|
var owner = that.get();
|
||||||
if (!owner) {
|
if (!owner) {
|
||||||
return;
|
return;
|
||||||
@ -82,11 +82,16 @@ export class EditableTextBase extends common.EditableTextBase {
|
|||||||
this._android.setOnFocusChangeListener(focusChangeListener);
|
this._android.setOnFocusChangeListener(focusChangeListener);
|
||||||
|
|
||||||
var editorActionListener = new android.widget.TextView.OnEditorActionListener({
|
var editorActionListener = new android.widget.TextView.OnEditorActionListener({
|
||||||
onEditorAction: function (textView: android.widget.TextView, actionId: number, event: android.view.KeyEvent): boolean {
|
onEditorAction: function(textView: android.widget.TextView, actionId: number, event: android.view.KeyEvent): boolean {
|
||||||
var owner = that.get();
|
var owner = that.get();
|
||||||
if (owner && event.getKeyCode() === android.view.KeyEvent.KEYCODE_ENTER) {
|
if (owner) {
|
||||||
owner.dismissSoftInput();
|
if (!event) {
|
||||||
owner._onReturnPress();
|
owner.dismissSoftInput();
|
||||||
|
}
|
||||||
|
else if (event.getKeyCode() === android.view.KeyEvent.KEYCODE_ENTER) {
|
||||||
|
owner.dismissSoftInput();
|
||||||
|
owner._onReturnPress();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -115,11 +120,11 @@ export class EditableTextBase extends common.EditableTextBase {
|
|||||||
|
|
||||||
public focus(): boolean {
|
public focus(): boolean {
|
||||||
var result = super.focus();
|
var result = super.focus();
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
utils.ad.showSoftInput(this._nativeView);
|
utils.ad.showSoftInput(this._nativeView);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +164,7 @@ export class EditableTextBase extends common.EditableTextBase {
|
|||||||
|
|
||||||
this._android.setInputType(newInputType);
|
this._android.setInputType(newInputType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public _onReturnKeyTypePropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
public _onReturnKeyTypePropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
||||||
if (!this._android) {
|
if (!this._android) {
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user