3

We have added an iOS module which contains a library (.a) to a simple keyboard and textfield titanium project.

The library uses quite a lot of javascript via UIWebView and it communicates back to the application via frames.

The library is very stable and reliable when using it inside an iOS project but is causing issues when integrated with a titanium module.

Here is a simple version of the problem code

var module = require ('com.module.test');

var win1 = Titanium.UI.createWindow({  
    backgroundColor:'#fff'
});

var cancelKb = Titanium.UI.createButton({
    title : "Cancel",
    style : Ti.UI.iPhone.SystemButtonStyle.BORDERED
});
cancelKb.addEventListener('click',function(e){tf.backgroundColor='#faa'; tf.blur(); });

var doneKb = Titanium.UI.createButton({
    title : "Done",
    style : Ti.UI.iPhone.SystemButtonStyle.DONE
});
doneKb.addEventListener('click',function(e){tf.backgroundColor='#aaf'; tf.blur(); });

var tf = Ti.UI.createTextField({
    hintText : "Enter code",
    top : 30,
    height : 44,
    left : 5,
    right : 5,
    paddingLeft : 20,
    clearButtonMode : Ti.UI.INPUT_BUTTONMODE_ALWAYS,
    autocorrect : false,
    visible : true,
    zIndex : 99,
    returnKeyType : Ti.UI.RETURNKEY_DONE,
    keyboardType : Ti.UI.KEYBOARD_PHONE_PAD //UI.KEYBOARD_NUMBERS_PUNCTUATION,
});
var flexspace = Titanium.UI.createButton({
    systemButton : Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE
});

tf.keyboardToolbar = [cancelKb, flexspace, doneKb];
win1.add(tf);
win1.open();
tf.focus();

If the following var module = require ('com.module.test'); isn't included the keyboard toolbar buttons work fine multiple times.

Including this module will work until the keyboard is dismissed the first time, and then the "Cancel" and "Done" buttons will no longer respond when the keyboard becomes refocused.

Ben Avery
  • 1,724
  • 1
  • 20
  • 33
  • Do Your module use NSNotificationCenter with UIKeyboard or any changes over window focus? Have you tried add event listener of change and blur to tf variable for log events? Do the buttons appear, but do not work? – Alejandro F. Carrera Sep 08 '14 at 23:45

0 Answers0