diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIText.java b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIText.java index b5cc0adbc88..0af9c82ac5d 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIText.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIText.java @@ -135,6 +135,22 @@ public void onLayoutChange( this.tv.setOnEditorActionListener(this); this.tv.setOnFocusChangeListener(this); this.tv.setIncludeFontPadding(true); + if (proxy.hasListeners("empty")) { + this.tv.setOnKeyListener(new View.OnKeyListener() + { + @Override + public boolean onKey(View v, int keyCode, KeyEvent event) + { + if (tv.getText().length() == 0) { + KrollDict data = new KrollDict(); + data.put("keyCode", keyCode); + fireEvent("empty", data); + } + return false; + } + }); + } + if (field) { this.tv.setGravity(Gravity.CENTER_VERTICAL | Gravity.START); } else { diff --git a/apidoc/Titanium/UI/TextField.yml b/apidoc/Titanium/UI/TextField.yml index 20661b799e8..f107ba0a6a4 100644 --- a/apidoc/Titanium/UI/TextField.yml +++ b/apidoc/Titanium/UI/TextField.yml @@ -610,6 +610,15 @@ events: summary: New value of the field. type: String + - name: empty + summary: Fired when the field is empty and you press backspace key again. + since: {android: "12.4.0"} + platforms: [android] + properties: + - name: keyCode + summary: Key code of the key. + type: Number + - name: focus summary: Fired when the field gains focus. properties: