Titanium JIRA Archive
Appcelerator Community (AC)

[AC-6509] Picker's focus event not working on Android

GitHub Issuen/a
TypeBug
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
ReporterNaman Vishoi
AssigneeAbir Mukherjee
Created2020-03-19T14:27:45.000+0000
Updated2020-03-30T08:56:36.000+0000

Description

We have a screen where on "return" event of a text field, we are calling the focus event of picker. But it doesn't pop-up the picker. To reproduce this issue, download the code from below shared link. https://drive.google.com/open?id=1o3XYemcFsvxauHYWc8x0MI1aj7D484SS Launch the app on Android, type something in the LastName text field, and then press enter/next on the keyboard. It should focus on the picker, but instead it's focusing on the last text field. Can you please look into this issue and patch the fix to 8.3.0/8.3.1 ? Thanks

Comments

  1. Rene Pot 2020-03-23

    Hi, could you please attach a compact standalone app, single file, titanium classic: index.js basically.
  2. Naman Vishoi 2020-03-27

       var lastNameTxtField;
       var picker;
       
         var win = Ti.UI.createWindow({
           title: 'picker',
           backgroundColor: '#fff'
         });
       
         var createAccountContainer = Ti.UI.createView({
           top: '8dp',
           left: '20dp',
           right: '20dp',
           height: Titanium.UI.SIZE,
           width: Titanium.UI.FILL,
           backgroundColor: 'white',
           bottom: '8dp',
           layout: 'vertical'
         });
       
         var firstNameLbl = Ti.UI.createLabel({
           text: "First name",
           height: Titanium.UI.SIZE,
           width: Titanium.UI.FILL,
           top: '8dp',
           bottom: '0dp',
           left: '16dp',
           right: '16dp',
           font: {
             fontSize: '16sp'
           },
           textAlign: Titanium.UI.TEXT_ALIGNMENT_LEFT,
           color: '#3D5791'
         });
       
          var firstNameTxtField = Ti.UI.createTextField({
           top: '10dp',
           height: '40',
           borderColor: 'gray',
           hintText: 'First name',
           returnKeyType: "Titanium.UI.RETURNKEY_NEXT",
           width: Ti.UI.FILL,
           bottom: '4dp',
           left: '16dp',
           right: '16dp',
           font: {
             fontSize: '16sp'
           },
           color: '#4d4d4d',
           verticalAlign: Titanium.UI.TEXT_VERTICAL_ALIGNMENT_CENTER
         });
       
         var lastNameLbl = Ti.UI.createLabel({
           text: "Last name",
           height: Titanium.UI.SIZE,
           width: Titanium.UI.FILL,
           top: '8dp',
           bottom: '0dp',
           left: '16dp',
           right: '16dp',
           font: {
             fontSize: '16sp'
           },
           textAlign: Titanium.UI.TEXT_ALIGNMENT_LEFT,
           color: '#3D5791'
         });
       
         lastNameTxtField = Ti.UI.createTextField({
           top: '10dp',
           height: '40',
           borderColor: 'gray',
           hintText: 'Last name',
           returnKeyType: "Titanium.UI.RETURNKEY_NEXT",
           width: Ti.UI.FILL,
           bottom: '4dp',
           left: '16dp',
           right: '16dp',
           font: {
             fontSize: '16sp'
           },
           color: '#4d4d4d',
           verticalAlign: Titanium.UI.TEXT_VERTICAL_ALIGNMENT_CENTER
         });
       
         var caseIdtypeLbl = Ti.UI.createLabel({
           text: "Case Id",
           height: Titanium.UI.SIZE,
           width: Titanium.UI.FILL,
           top: '8dp',
           bottom: '0dp',
           left: '16dp',
           right: '16dp',
           font: {
             fontSize: '16sp'
           },
           textAlign: Titanium.UI.TEXT_ALIGNMENT_LEFT,
           color: '#3D5791'
         });
       
         var pickerContainer = Ti.UI.createView({
           height: Ti.UI.SIZE
         });
       
         picker = Titanium.UI.createPicker({
           height: '50dp',
           top: '10dp',
           left: '16dp',
           color: 'black',
           backgroundColor: 'grey',
           width: '100%'
         });
       
         var selectedValueLbl = Ti.UI.createLabel({
           text: "How would you like to identify yourself?",
           height: Titanium.UI.SIZE,
           width: Titanium.UI.FILL,
           top: '8dp',
           bottom: '0dp',
           left: '16dp',
           right: '16dp',
           font: {
             fontSize: '16sp'
           },
           textAlign: Titanium.UI.TEXT_ALIGNMENT_LEFT,
           color: '#3D5791'
         });
       
         var selectedValue = Ti.UI.createTextField({
           top: '10dp',
           height: '40',
           borderColor: 'gray',
           hintText: 'Identify',
           returnKeyType: "Titanium.UI.RETURNKEY_DONE",
           width: Ti.UI.FILL,
           bottom: '4dp',
           left: '16dp',
           right: '16dp',
           font: {
             fontSize: '16sp'
           },
           color: '#4d4d4d',
           verticalAlign: Titanium.UI.TEXT_VERTICAL_ALIGNMENT_CENTER
         });
       
         win.add(createAccountContainer);
         createAccountContainer.add(firstNameLbl);
         createAccountContainer.add(firstNameTxtField);
         createAccountContainer.add(lastNameLbl);
         createAccountContainer.add(lastNameTxtField);
         createAccountContainer.add(caseIdtypeLbl);
       
         pickerContainer.add(picker);
         createAccountContainer.add(pickerContainer);
       
         createAccountContainer.add(selectedValueLbl);
         createAccountContainer.add(selectedValue);
       
         var pickerValues = ['Case Num', 'SSN Num'];
         var data = [];
       
         for (var i = 0; i < pickerValues.length; i++) {
           data[i] = Ti.UI.createPickerRow({
             title: pickerValues[i]
           });
         }
         picker.add(data);
         picker.selectionIndicator = true;
       
         picker.setSelectedRow(0, 0);
       
       
       function focusOnPicker(e) {
           picker.focus();
       }
       
       lastNameTxtField.addEventListener('return', focusOnPicker);
       
       win.open();
       
  3. Naman Vishoi 2020-03-27

    I have uploaded the whole titanium classic app at https://drive.google.com/file/d/1I0Kidowi5gl-GV28b2FyqVVyTl8h38er/view?usp=sharing Also pasted the single file content in the comment above
  4. Rene Pot 2020-03-30

    Hi, If you check the documentation you can see the focus event doesn't exist in a picker, however, when you change the row in the callback function to this:
       picker.setSelectedRow(0,picker.selectedValue);
       
    And you add this property to the picker:
       selectionOpens: true
       
    You should see the picker open when you click the return key while focussed on the lastname field. let me know if this solves it for you, then we can close the ticket.

JSON Source