[AC-5483] KEYPRESSED does not work on Android Devices
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Resolved |
Resolution | Invalid |
Resolution Date | 2018-01-05T20:31:15.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | android |
Reporter | Andreas Pingas |
Assignee | Shak Hossain |
Created | 2018-01-02T14:51:17.000+0000 |
Updated | 2018-01-08T15:55:08.000+0000 |
Description
Hello,
keypressed in TextField does not work on all the Android devices.
Also, from 7.0.1 titanioum sdk does not work at all.
Please check. Thank you in advance.
Best,
Andreas
Hello [~andreas.pingas], Thanks for sharing with us. It would be better if you can provide a sample project to reproduce the issue on our end. Also share your environment details . Best
var win = Titanium.UI.createWindow(); var phoneNumberText = Titanium.UI.createTextField({ height:'60dip', top:'0dip', left:'10dip', right:'10dip', hintText:'Phone Number', textAlign:Titanium.UI.TEXT_ALIGNMENT_LEFT, verticalAlign:Titanium.UI.TEXT_VERTICAL_ALIGNMENT_CENTER, color:'#ED4030', borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED, keyboardType:Titanium.UI.KEYBOARD_TYPE_PHONE_PAD, focusable:true }); win.add(phoneNumberText); function isValid(e) { } phoneNumberText.addEventListener('keypressed', function(e) { Ti.API.info('keypressed'); isValid(); }); win.open();
Hello, To my understanding this event only fired when a hardware key is pressed. Not pressing soft keyboard in the display. See docs: "A keypressed event is generated by pressing a hardware key. On Android, this event can only be fired when the property focusable is set to true." Thanks.
In titanium sdk 6.3.0 worked properly whereas in titanium sdk 7.0.1, by changing the sdk in some devices works and in some others does not. However, even in 6.3.0 it was not always working properly as sometimes works and sometimes does not. As a result i have replaced it with : var myValue = ''; phoneNumberText.addEventListener('change', function(e) { Ti.API.info('change'); if (e.value != myValue) { myValue = e.value; isValid(); } }); You need to make a change to prevent infinity loop