GitHub Issue | n/a |
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-01-14T17:14:23.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 3.0.2, Release 3.1.0, 2013 Sprint 01 API, 2013 Sprint 01, 2013 Sprint 02 |
Components | iOS |
Labels | defect, ios, module_require, parity, qe-testadded, regression, titanbeta |
Reporter | Shawn Lipscomb |
Assignee | Vishal Duggal |
Created | 2012-12-20T23:10:00.000+0000 |
Updated | 2013-01-24T10:16:07.000+0000 |
Problem
There is a regression in SDK 3.0.0.GA that prevents a button's click event from firing when the button is created in a require()d unit.
Works in SDK 2.1.4.GA
Broken in SDK 3.0.0.GA
Note that this works fine on Android under SDK 3.0.0.GA (and SDK 2.1.4.GA)...the problem only exists on iOS.
Testcase
Run the following code and click the button. A console message should appear when the button is clicked, and the button's title should change to "Clicked!", but under SDK 3.0.0.GA this does not happen.
Note that this testcase is reduced down to the smallest reproducable code from a very large app.
{panel:title=app.js}
var win1=Ti.UI.createWindow({url:'win1.js',
fullscreen:false,
navBarHidden:false});
win1.ButtonMaker=require('ButtonMaker');
win1.open();
{panel}
{panel:title=win1.js}
var MainWin=Ti.UI.currentWindow;
var ButtonMaker=MainWin.ButtonMaker;
function NewButtonClick(evt)
{
Ti.API.info('Button was clicked');
Button1.title='Clicked!';
}
var Button1=ButtonMaker.NewButton(MainWin,'Click Me',NewButtonClick);
{panel}
{panel:title=ButtonMaker.js}
exports.NewButton=function(Parent,Caption,ClkEvent)
{
var AButton=Ti.UI.createButton({title:Caption,
width:'122dp',
height:'44dp'
});
Parent.add(AButton);
AButton.addEventListener('click',ClkEvent);
return AButton;
};
{panel}
Shawn, did you notice the following warning?
Change win1.js code to require module from there, and it will work.
Max, yes I noticed that warning. In the past (pre 3.0 SDK) we've received that warning with no detrimental effect. We've been using require() like in my example for a year and a half now with many apps dedicated to our CommonJS framework. Moving all of our require() statements into every unit is not a practical solution for us. There are dozens of them with complex relationships (units that require units that require units). The example I gave is a significantly reduced bit of code to make it easy to see the problem. My code works fine in Android. It works fine in SDK 2.1.4. Something in 3.0.0 caused a regression. Please see if this can be addressed. Thanks.
Shawn--we'll be fixing this the next sprint, which should hopefully be in time for your application deployment (though you will need an unofficial build).
Thanks, Ingo...looking forward to it.
Pull pending https://github.com/appcelerator/titanium_mobile/pull/3668
Pull merged.
Any chance of this being merged into the 3.0.1 SDK?
@Vishal--I added a backport request. Can we see if this can be addressed?
backport PR https://github.com/appcelerator/titanium_mobile/pull/3718 Related JIRA ticket is TIMOB-12299
Now the button is changed to 'Clicked' and console message also appears. Environment used for verification - -iOS 6.0 (simulator) -Mac OSX 10.8 -Titanium Mobile SDK 3.1.0.v20130114171802 -Titanium Studio 3.0.1.201212181159
Verified fixed in SDK 3.1.0.v20130114171802. Thanks!
Also verified fixed in SDK 3.0.2.v20130122172624.