[AC-1945] KeyboardToolbar issues
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Cannot Reproduce |
Resolution Date | 2014-01-12T04:48:55.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | iphone, keyboardtoolbar |
Reporter | Hariharan Ganesan |
Assignee | Ritu Agrawal |
Created | 2014-01-07T05:33:28.000+0000 |
Updated | 2016-03-08T07:40:52.000+0000 |
Description
am using titanium studio code .I have some issues from keyboard toolbar.If i have multiple text fields tab to next or click to next mean first time properly showed the previous and next button.But when am refocusing or click the reverse the field it does not show the previous and next button.So please any one advice me.
Thanks,
Hari
Please provide a simple test case to reproduce this issue and we would be happy to investigate this issue.
var sign_up_windows = function() { //------------------------Basic Includes------------------------ // Ti.include('ui/basic_views.js'); Ti.include('ui/advanced_views.js'); Ti.include('common/api.js'); var activity_indicators = require('ui/ui'); var activity_indicator = ''; //------------------------Basic Includes------------------------ // //------------------------Window Element------------------------ // var sign_up_window = new_window('window'); var scrollView1 = Ti.UI.createScrollView({ contentWidth:'auto', contentHeight:'auto', top:0, showVerticalScrollIndicator:true, showHorizontalScrollIndicator:true }); var slidein = Titanium.UI.createAnimation({ bottom : -43 }); var slideout = Titanium.UI.createAnimation({ bottom : -250 }); //------------------------Window Element------------------------ // //------------------------Header Section------------------------ // var sign_up_image_view = new_view('sign_up_image_view'); var sign_up_image = new_image('sign_up_image', 'images/logo.png'); sign_up_image_view.add(sign_up_image); scrollView1.add(sign_up_image_view); //------------------------Header Section------------------------ // var sign_up_view = v_view("sign_up_view"); scrollView1.add(sign_up_view); var sign_up_now = new_label('sign_up_now', 'Quick Sign Up'); sign_up_view.add(sign_up_now); var first_name_view = new_view("first_name_view"); var last_name_view = new_view("last_name_view"); var age_view = new_view("age_view"); var sex_view = new_view("sex_view"); var email_view = new_view("email_view"); var password_view = new_view("password_view"); var signup_button = new_button('signup_button', 'images/greenbtn.png', 'images/greenbtn_select.png'); signup_button.selectedColor = "#fff"; signup_button.title = "Sign Up"; var first_name_field = new_text('first_name_field', 'First Name'); var last_name_field = new_text('last_name_field', 'Last Name'); var age_field = l_label('age_field_label', 'D.O.B'); var sex_field = l_label('sex_field_label', 'Sex'); var email_field = new_email('email_field', 'Email'); var password_field = new_password('password_field', 'Password'); first_name_field.returnKeyType = Titanium.UI.RETURNKEY_NEXT; last_name_field.returnKeyType = Titanium.UI.RETURNKEY_NEXT; email_field.returnKeyType = Titanium.UI.RETURNKEY_NEXT; password_field.returnKeyType = Titanium.UI.RETURNKEY_DONE; first_name_view.add(first_name_field); last_name_view.add(last_name_field); age_view.add(age_field); sex_view.add(sex_field); email_view.add(email_field); password_view.add(password_field); sign_up_view.add(first_name_view); sign_up_view.add(last_name_view); sign_up_view.add(age_view); sign_up_view.add(sex_view); sign_up_view.add(email_view); sign_up_view.add(password_view); sign_up_view.add(signup_button); signup_button.addEventListener('click', function() { sign_me_up(); }); //------------------------Sign In Section------------------------ // var already_registered = new_view('already_registered'); var already_registered_label = new_label("already_registered_label", "Already have an account?"); var log_in_button = new_button('log_in_button', 'images/redactionbtn.png', 'images/redactionbtn_select.png'); log_in_button.selectedColor = "#fff"; log_in_button.title = "Log In"; scrollView1.add(already_registered); already_registered.add(already_registered_label); already_registered.add(log_in_button); log_in_button.addEventListener('click', function() { sign_up_window.close({ transition : Ti.UI.iPhone.AnimationStyle.CURL_DOWN }); }); //------------------------Sign In Section------------------------ // var cancel = Titanium.UI.createButton({ title : 'Cancel', style : Titanium.UI.iPhone.SystemButtonStyle.BORDERED }); var spacer = Titanium.UI.createButton({ systemButton : Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE }); var done = Titanium.UI.createButton({ title : 'Done', style : Titanium.UI.iPhone.SystemButtonStyle.DONE }); var next = Titanium.UI.createButton({ title : 'Next', style : Titanium.UI.iPhone.SystemButtonStyle.DONE }); var spacer = Titanium.UI.createButton({ systemButton : Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE }); var toolbar = Titanium.UI.createToolbar({ top : 0, items : [cancel, spacer] }); // first_name_field.keyboardToolbar = [cancel, spacer, next]; last_name_field.keyboardToolbar = [cancel, spacer, next]; sex_field.keyboardToolbar = [cancel, spacer, next]; email_field.keyboardToolbar = [cancel, spacer, next]; password_field.keyboardToolbar = [cancel, spacer, done]; var pickerView = Titanium.UI.createView({ height : 250, bottom : -250, visibleItems : 3 }); scrollView1.add(pickerView); var active_picker = ""; var minDate = new Date(); minDate.setFullYear(1900); minDate.setMonth(0); minDate.setDate(1); var maxDate = new Date(); maxDate.setFullYear(1999); maxDate.setMonth(11); maxDate.setDate(31); var value = new Date(); maxDate.setFullYear(1999); var age_picker = Ti.UI.createPicker({ type : Ti.UI.PICKER_TYPE_DATE, top : 43, minDate : minDate, maxDate : maxDate, value : value }); var sex_picker = Titanium.UI.createPicker({ top : 43 }); sex_picker.selectionIndicator = true; var sex_values = [Titanium.UI.createPickerRow({ title : 'Male', id : 1 }), Titanium.UI.createPickerRow({ title : 'Female', id : 2 })]; sex_picker.add(sex_values); //pickerView.add(toolbar); sex_picker.addEventListener('change', function(e) { //alert('sex change'); sex_field.text = sex_picker.getSelectedRow(0).title; sex_field.color = "#000000"; email_field.focus(); toolbar.items = [cancel, spacer, next]; }); var dob_date = ""; age_picker.addEventListener('change', function(e) { //alert('age change'); dob_date = e.value; today_date = dob_date.getDate(); today_month = dob_date.getMonth() + 1; today_year = dob_date.getFullYear(); age_field.text = today_date + "/" + today_month + "/" + today_year; age_field.color = "#000000"; toolbar.items = [cancel, spacer, next]; }); //pickerView.add(sex_picker); sex_view.addEventListener('click', function() { //alert('sex click'); //animate_up(); pickerView.animate(slidein); first_name_field.blur(); last_name_field.blur(); email_field.blur(); password_field.blur(); active_field = sex_field; toolbar.items = [cancel, spacer, next]; if (active_picker != sex_picker) { pickerView.remove(age_picker); active_picker == age_picker; pickerView.add(sex_picker); } }); age_view.addEventListener('click', function(e) { //alert('age click'); active_field = age_field; //animate_up(); pickerView.animate(slidein); first_name_field.blur(); last_name_field.blur(); email_field.blur(); password_field.blur(); toolbar.items = [cancel, spacer, next]; if (active_picker != age_picker) { pickerView.remove(sex_picker); active_picker == age_picker; pickerView.add(age_picker); } }); // //------------------------Sign In Section------------------------ // var active_field = ""; first_name_field.addEventListener('focus', function(e) { active_field = first_name_field; //animate_up(); //alert("hi"); first_name_field.keyboardToolbar = [cancel, spacer, next]; //pickerView.animate(slideout); }); first_name_field.addEventListener('return', function(e) { last_name_field.focus(); }); last_name_field.addEventListener('focus', function(e) { active_field = last_name_field; //pickerView.animate(slideout); //animate_up(); last_name_field.keyboardToolbar = [cancel, spacer, next]; }); last_name_field.addEventListener('return', function(e) { //alert("keyboard showing"); //age_field.focus(); age_view.fireEvent('click'); }); email_field.addEventListener('focus', function(e) { //alert('email field'); //animate_up(); pickerView.remove(sex_picker); //email_field.focus(); active_field = email_field; email_field.keyboardToolbar = [cancel, spacer, next]; }); email_field.addEventListener('return', function(e) { password_field.focus(); }); password_field.addEventListener('focus', function(e) { //animate_up(); //pickerView.animate(slideout); active_field = password_field; password_field.keyboardToolbar = [cancel, spacer, done]; }); password_field.addEventListener('return', function() { sign_me_up(); }); function alert_me(title, message) { var alertalert = Ti.UI.createAlertDialog(); alertalert.title = title; alertalert.message = message; alertalert.show(); } function sign_me_up() { if (first_name_field.value == '' || first_name_field.value == null || first_name_field.value == 'undefined') { first_name_field.focus(); alert_me('Error', 'Input First Name !'); } else if (last_name_field.value == '' || last_name_field.value == null || last_name_field.value == 'undefined') { last_name_field.focus(); alert_me('Error', 'Input Last Name !'); } else if (age_field.text == 'D.O.B') { age_field.fireEvent('click'); alert_me('Error', 'Confirm your Age !'); } else if (sex_field.text == 'Sex') { sex_field.fireEvent('click'); alert_me('Error', 'Confirm your Gender !'); } else if (email_field.value == '' || email_field.value == null || email_field.value == 'undefined') { email_field.focus(); alert_me('Error', 'Input Email !'); } else if (password_field.value == '' || password_field.value == null || password_field.value == 'undefined') { password_field.focus(); alert_me('Error', 'Input Password !'); } else { //animate_down(); activity_indicator = new activity_indicators('Logging In...'); activity_indicator.open(); var return_repsonse; var xhr = Ti.Network.createHTTPClient({ onload : function() { myjson = JSON.parse(this.responseText); check_my_signup(myjson); }, onerror : function(e) { Ti.API.debug("STATUS: " + this.status); Ti.API.debug("TEXT: " + this.responseText); Ti.API.debug("ERROR: " + e.error); activity_indicator.close({ opacity : 0, duration : 1000 }, function() { if (Titanium.Network.online) { alert('No reponse from server.'); } else { alert('Please Check your Internet connectivity.'); } }); }, timeout : 5000 }); var params = "api_token=" + api_token_code; params = params + "&user[first_name]=" + first_name_field.value; params = params + "&user[last_name]=" + last_name_field.value; params = params + "&user[gender]=" + sex_field.text; params = params + "&user[date_of_birth]=" + age_field.text; params = params + "&user[email]=" + email_field.value; params = params + "&user[password]=" + password_field.value; params = params + "&user[password_confirmation]=" + password_field.value; params = params + "&user[terms]=1"; xhr.open('POST', main_url + 'users.json', true); xhr.send(params); } } function check_my_signup(myjson) { activity_indicator.close({ opacity : 0, duration : 1000 }, function() { if (myjson[0].id >= 1) { alert(myjson[0].id); logged_user_id = myjson[0].id; var main_windows = require('nav/main_window'); var main_window = new main_windows(myjson); main_window.open({ animated : true, }); } else if (myjson[0].code == 0) { alertalert.title = "Sign Up Error"; alertalert.message = "Invalid Params !"; alertalert.buttonNames = ['Retry']; alertalert.show(); } }); } cancel.addEventListener('click', function() { animate_down(); pickerView.animate(slideout); }); next.addEventListener('click', function() { first_name_view.add(first_name_field); last_name_view.add(last_name_field); age_view.add(age_field); sex_view.add(sex_field); email_view.add(email_field); password_view.add(password_field); if (active_field == first_name_field) { last_name_field.focus(); } else if (active_field == last_name_field) { age_field.fireEvent('click'); } else if (active_field == age_field) { sex_field.fireEvent('click'); } else if (active_field == sex_field) { email_field.focus(); } else if (active_field == email_field) { password_field.focus(); } else if (active_field == password_field) { ; } else { ; } }); done.addEventListener('click', function() { //animate_down(); }); function animate_up() { sign_up_window.animate({ top : -170, curve : Ti.UI.ANIMATION_CURVE_EASE_IN_OUT, duration : 500 }); } function animate_down() { sign_up_window.animate({ top : 0, curve : Ti.UI.ANIMATION_CURVE_EASE_IN_OUT, duration : 500 }); first_name_field.blur(); last_name_field.blur(); email_field.blur(); password_field.blur(); pickerView.animate(slideout); } sign_up_window.add(scrollView1); return sign_up_window; }; module.exports = sign_up_windows; //--------------------------------------------------------// /******************************************** ************@author Sahil Grover************ ********************************************/ //--------------------------------------------------------// here am i attached my code
I would appreciate if you can trim down the code here and provide a simpler test case. It is hard to understand the provided code.
Resolving this ticket as we have not been able to reproduce this issue with our own test case and the provided test case is too complex to build and debug. We would be happy to reopen this ticket and investigate this issue further if you can provide a simple test case.