mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +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 {
|
export abstract class EditableTextBase extends TextBase implements EditableTextBaseDefinition {
|
||||||
public static blurEvent = "blur";
|
public static blurEvent = "blur";
|
||||||
|
public static focusEvent = "focus";
|
||||||
|
|
||||||
public keyboardType: KeyboardType;
|
public keyboardType: KeyboardType;
|
||||||
public returnKeyType: ReturnKeyType;
|
public returnKeyType: ReturnKeyType;
|
||||||
|
@ -77,6 +77,7 @@ function initializeEditTextListeners(): void {
|
|||||||
clearTimeout(dismissKeyboardTimeoutId);
|
clearTimeout(dismissKeyboardTimeoutId);
|
||||||
dismissKeyboardTimeoutId = undefined;
|
dismissKeyboardTimeoutId = undefined;
|
||||||
}
|
}
|
||||||
|
owner.notify({ eventName: EditableTextBase.focusEvent, object: owner });
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (owner._dirtyTextAccumulator || owner._dirtyTextAccumulator === "") {
|
if (owner._dirtyTextAccumulator || owner._dirtyTextAccumulator === "") {
|
||||||
|
@ -9,6 +9,7 @@ import { TextBase, Property, CssProperty, Style, Color, FormattedString } from "
|
|||||||
*/
|
*/
|
||||||
export class EditableTextBase extends TextBase {
|
export class EditableTextBase extends TextBase {
|
||||||
public static blurEvent: string;
|
public static blurEvent: string;
|
||||||
|
public static focusEvent: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets or sets the soft keyboard type.
|
* Gets or sets the soft keyboard type.
|
||||||
|
@ -33,6 +33,13 @@ class UITextFieldDelegateImpl extends NSObject implements UITextFieldDelegate {
|
|||||||
return true;
|
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) {
|
public textFieldDidEndEditing(textField: UITextField) {
|
||||||
const owner = this._owner.get();
|
const owner = this._owner.get();
|
||||||
if (owner) {
|
if (owner) {
|
||||||
|
@ -29,10 +29,11 @@ class UITextViewDelegateImpl extends NSObject implements UITextViewDelegate {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public textViewDidBeginEditing(textView: UITextView) {
|
public textViewDidBeginEditing(textView: UITextView): void {
|
||||||
var owner = this._owner.get();
|
const owner = this._owner.get();
|
||||||
if (owner) {
|
if (owner) {
|
||||||
owner._isEditing = true;
|
owner._isEditing = true;
|
||||||
|
owner.notify({ eventName: TextView.focusEvent, object: owner });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user