[TIMOB-12511] BlackBerry: All modules should support event listeners.
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-02-01T18:17:12.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 3.1.0, 2013 Sprint 03 BB, 2013 Sprint 03 |
Components | BlackBerry |
Labels | n/a |
Reporter | Josh Roesslein |
Assignee | Josh Roesslein |
Created | 2013-01-31T06:55:43.000+0000 |
Updated | 2013-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.
Created pull request [#18](https://github.com/appcelerator/titanium_mobile_blackberry/pull/18) to resolve issue.