Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16833] BlackBerry: Ti.UI.createButton has inconsistent results

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2014-06-12T11:59:47.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsBlackBerry
Labelsblackberry, module_button, qe-closed-3.3.0, qe-testadded
ReporterSteven Saracut
AssigneeShak Hossain
Created2014-04-07T21:31:31.000+0000
Updated2014-06-18T11:48:46.000+0000

Description

Why does creating 2 buttons inline like this cause the following output: [INFO] button1 type: [object TiUIButtonProxy] [INFO] button2 type: function () { [native code] }

// Create a Button.
	var button1 = Ti.UI.createButton({
		title : 'button1',
		height : Ti.UI.SIZE,
		width : Ti.UI.SIZE
	});
	
	Ti.API.info("button1 type: " + button1);
	
	// Listen for click events.
	button1.addEventListener('click', function() {
		Ti.API.info('\'button1\' was clicked! : pre-eventListener');
		
	});
	
	// Add to the parent view.
	self.mainView.add(button1);
	
	// Create a Button.
	var button2 = Ti.UI.createButton({
		title : 'button2',
		height : Ti.UI.SIZE,
		width : Ti.UI.SIZE
	});

	Ti.API.info("button2 type: " + button2);
		
	// Listen for click events.
	button2.addEventListener('click', function() {
		Ti.API.info('\'button2\' was clicked! : pre-eventListener');
		
	});
	
	// Add to the parent view.
	self.mainView.add(button2);

Comments

  1. Pedro Enrique 2014-04-09

    This is due to the way the V8 objects are created internally. For some reason it fails to add the properties sometimes. I have already found the bug, PR coming soon. This is critical since it is very inconsistent. This code also fails in the current code:
       var win = Ti.UI.createWindow();
       var btn = Ti.UI.createButton();
       btn.addEventListener('click',function(){
       	var file = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory);
       	Ti.API.info(file.getDirectoryListing());
       });
       win.open();
       win.add(btn);
       
  2. Pedro Enrique 2014-04-09

    Pending PR: https://github.com/appcelerator/titanium_mobile_blackberry/pull/216
  3. Pedro Enrique 2014-04-10

    Mauro, it broke after 3.2.2 and I just fixed it. Can you try with Master???? Thanks!
  4. Steven Saracut 2014-04-14

    I pulled master and can confirm it worked for me now.
  5. Priya Agarwal 2014-06-18

    Verified with test environment: Appcelerator-Studio:3.3.0.201406171619 Sdk:3.3.0.v20140617161713 acs:1.0.14 alloy:1.4.0-rc npm:1.3.2 titanium:3.3.0-rc titanium-code-processor:1.1.1 xcode:5.1.1 OS:Maverick(10.9.3) Device:Blackberry Z10 Working as expected. Hence closing the issue

JSON Source