Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12511] BlackBerry: All modules should support event listeners.

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2013-02-01T18:17:12.000+0000
Affected Version/sn/a
Fix Version/sRelease 3.1.0, 2013 Sprint 03 BB, 2013 Sprint 03
ComponentsBlackBerry
Labelsn/a
ReporterJosh Roesslein
AssigneeJosh Roesslein
Created2013-01-31T06:55:43.000+0000
Updated2013-04-01T21:58:07.000+0000

Description

Developers should be able to add and fire events on module objects (ex: API, App).

Acceptance Test

function listener() {
	Ti.API.info('Event from ' + this.module);
}

function testEvent(module, name) {
    module.addEventListener('foo', listener.bind({module:name}));
    module.fireEvent('foo');
}

testEvent(Ti, 'Ti');
testEvent(Ti.API, 'API');
testEvent(Ti.App, 'App');
testEvent(Ti.Codec, 'Codec');
testEvent(Ti.Database, 'Database');
testEvent(Ti.Network, 'Network');
testEvent(Ti.Platform, 'Platform');
testEvent(Ti.UI, 'UI');

var win = Ti.UI.createWindow();

var button = Ti.UI.createButton({
	title: 'Click, me!',
	width: 300, height: 300
});
win.add(button);

button.addEventListener('click', function() {
	Ti.API.info('click!');
});

button.addEventListener('foo', function() {
	Ti.API.info('foo!');
});
button.fireEvent('foo');

win.open();
1. Run the test case. 2. You should see events fire and log the module from which they came from in the logs. 3. You should also see a 'foo' event logged which was fired from the button. 4. Try clicking the button and you will see "click!" printed to confirm native events still work.

Comments

  1. Josh Roesslein 2013-02-01

    Created pull request [#18](https://github.com/appcelerator/titanium_mobile_blackberry/pull/18) to resolve issue.
  2. Lokesh Choudhary 2013-02-06

JSON Source