mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
Add a 'focus' even to text input fields (#4730)
This commit is contained in:

committed by
Hristo Hristov

parent
92471c660e
commit
f00ec1a966
@ -5,6 +5,7 @@ export * from "../text-base";
|
||||
|
||||
export abstract class EditableTextBase extends TextBase implements EditableTextBaseDefinition {
|
||||
public static blurEvent = "blur";
|
||||
public static focusEvent = "focus";
|
||||
|
||||
public keyboardType: KeyboardType;
|
||||
public returnKeyType: ReturnKeyType;
|
||||
|
@ -77,6 +77,7 @@ function initializeEditTextListeners(): void {
|
||||
clearTimeout(dismissKeyboardTimeoutId);
|
||||
dismissKeyboardTimeoutId = undefined;
|
||||
}
|
||||
owner.notify({ eventName: EditableTextBase.focusEvent, object: owner });
|
||||
}
|
||||
else {
|
||||
if (owner._dirtyTextAccumulator || owner._dirtyTextAccumulator === "") {
|
||||
|
@ -9,6 +9,7 @@ import { TextBase, Property, CssProperty, Style, Color, FormattedString } from "
|
||||
*/
|
||||
export class EditableTextBase extends TextBase {
|
||||
public static blurEvent: string;
|
||||
public static focusEvent: string;
|
||||
|
||||
/**
|
||||
* Gets or sets the soft keyboard type.
|
||||
|
@ -33,6 +33,13 @@ class UITextFieldDelegateImpl extends NSObject implements UITextFieldDelegate {
|
||||
return true;
|
||||
}
|
||||
|
||||
public textFieldDidBeginEditing(textField: UITextField): void {
|
||||
const owner = this._owner.get();
|
||||
if (owner) {
|
||||
owner.notify({ eventName: TextField.focusEvent, object: owner });
|
||||
}
|
||||
}
|
||||
|
||||
public textFieldDidEndEditing(textField: UITextField) {
|
||||
const owner = this._owner.get();
|
||||
if (owner) {
|
||||
|
@ -29,10 +29,11 @@ class UITextViewDelegateImpl extends NSObject implements UITextViewDelegate {
|
||||
return true;
|
||||
}
|
||||
|
||||
public textViewDidBeginEditing(textView: UITextView) {
|
||||
var owner = this._owner.get();
|
||||
public textViewDidBeginEditing(textView: UITextView): void {
|
||||
const owner = this._owner.get();
|
||||
if (owner) {
|
||||
owner._isEditing = true;
|
||||
owner.notify({ eventName: TextView.focusEvent, object: owner });
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user