Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-6745

Android: UI - TextField's "focus" event is fired without user interaction

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: High
    • Resolution: Cannot Reproduce
    • Affects Version/s: Release 1.7.5
    • Fix Version/s: 2013 Sprint 09
    • Component/s: Android
    • Labels:
    • Environment:
      • Titanium SDK version: 1.7.6 (11/22/11 14:11 194e8e6...)
      • Android 3.1
      • Lenovo Thinkpad Tablet
      • Windows XP SP3

      Description

      Behavior

      It seems that "focus" event doesn't work well on Android and this behavior cause awful user experience. To see the issue, run the test case below.

      Scroll to the bottom, but don't touch text fields. You'll see in the console output that text field fired "focus" event and that keyboard has shown on the screen.

      Also, scroll to the bottom, click "Click me!" button to open new window. Then, click "Close me!" button. ScrollView should be scrolled up to the text field that has "focus" (gained by a bug described above!), which creates awful user experience because user needs to scroll back to where he was before opening new window (ScrollView should not scroll after returning from newly created window).

      Test case

      app.js

      var win = Ti.UI.createWindow({
      	backgroundColor: '#000',
      	modal: true,
      	navBarHidden: true,
      	layout: 'vertical'
      });
       
      function createItem() {
      	var view = Ti.UI.createView({
      		height: 100,
      		width: '100%',
      		layout: 'horizontal'
      	});
      	
      	var label = Ti.UI.createLabel({
      		text: 'Testing ...',
      		width: '50%'
      	});
      	
      	var checkbox = Ti.UI.createSwitch({
      		style: Ti.UI.Android.SWITCH_STYLE_CHECKBOX
      	});
      	
      	view.add(label);
      	view.add(checkbox);
      	
      	return view;
      }
       
      function createTextField() {
      	
      	var view = Ti.UI.createView({
      		height: 100,
      		width: '100%',
      		backgroundColor: '#0ff',
      		layout: 'horizontal'
      	});
      	
      	var label = Ti.UI.createLabel({
      		text: 'Text field ...',
      		width: '50%'
      	});
      	
      	var textField = Ti.UI.createTextField({
      		width: '30%'
      	});
      	
      	textField.addEventListener('focus', function() {
      		Ti.API.info('Focus fired');
      	});
      	
      	view.add(label);
      	view.add(textField);
      	
      	return view;
      }
       
      var scrollView = Ti.UI.createScrollView({
      	layout: 'vertical',
      	backgroundColor: '#f00',
      	showVerticalScrollIndicator: true,
      	height: '100%',
      	width: '100%',
      	contentHeight: 'auto',
      	contentWidth: 'auto',
      	top: 0
      });
       
      for (var m = 0; m < 3; ++m) {
      	for (var i = 0; i < 20; ++i) {
      		scrollView.add(createItem());
      	}
      	var view = createTextField();
      	scrollView.add(view);
      }
       
      for (var j = 0; j < 20; ++j) {
      	scrollView.add(createItem());
      }
       
      var button = Ti.UI.createButton({ title: 'Click me!' });
       
      button.addEventListener('click', function() {
      	var context = Ti.UI.createWindow({
      		backgroundColor: '#000',
      		modal: true,
      		navBarHidden: true,
      		layout: 'vertical'
      	});
      	
      	var closeButton = Ti.UI.createButton({ title: 'Close me!' });
      	
      	closeButton.addEventListener('click', function() {
      		context.close();
      	});
      	
      	context.add(closeButton);
      	
      	context.open();
      });
       
      scrollView.add(button);
       
      win.add(scrollView);
       
      Ti.API.info('App runnning ...');
       
      win.open();
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jithinv@exalture.com jithinpv
                Reporter:
                ivan.skugor Ivan Skugor
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-11422
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Integration