void NativeDropDownObject::setupEvents(TiEventContainerFactory* containerFactory)
{
    NativeControlObject::setupEvents(containerFactory);
    TiEventContainer* eventClick = containerFactory->createEventContainer();
    events_.insert(tetCLICK, EventPairSmartPtr(eventClick, new DropDownEventHandler(eventClick)));
    QObject::connect(dropdown_, SIGNAL(selectedIndexChanged(int selectedIndex)), events_[tetCLICK]->handler(), SLOT(selectedIndexChanged(int selectedIndex)));
}
void NativeDateTimePickerObject::setupEvents(TiEventContainerFactory* containerFactory)
{
    NativeControlObject::setupEvents(containerFactory);
    TiEventContainer* eventChange = containerFactory->createEventContainer();
    eventChange->setDataProperty("type", tetCHANGE);
    events_.insert(tetCHANGE, EventPairSmartPtr(eventChange, new DateTimePickerEventHandler(eventChange)));
    QObject::connect(dateTimePicker_, SIGNAL(valueChanged(QDateTime)), events_[tetCHANGE]->handler(), SLOT(setValue(QDateTime)));
}
void NativeImageViewObject::setupEvents(TiEventContainerFactory* containerFactory)
{
    NativeControlObject::setupEvents(containerFactory);
    TiEventContainer* eventImageChanged = containerFactory->createEventContainer();
    eventImageChanged->setDataProperty("type", tetCHANGE);
    events_.insert(tetCHANGE, EventPairSmartPtr(eventImageChanged, new ImageViewEventHandler(eventImageChanged)));
    QObject::connect(imageView_, SIGNAL(imageChanged(const bb::cascades::Image)), events_[tetCHANGE]->handler(), SLOT(imageChanged(const bb::cascades::Image)));
}
void NativeOptionDialogObject::setupEvents(TiEventContainerFactory* containerFactory)
{
	NativeProxyObject::setupEvents(containerFactory);
    TiEventContainer* eventClick = containerFactory->createEventContainer();
    eventClick->setDataProperty("type", tetCLICK);
    events_.insert(tetCLICK, EventPairSmartPtr(eventClick, new NativeOptionDialogEventHandler(eventClick)));
    QObject::connect(dialog_, SIGNAL(finished(bb::system::SystemUiResult::Type)), events_[tetCLICK]->handler(), SLOT(clicked(bb::system::SystemUiResult::Type)));

}
int NativeProxyObject::setEventHandler(const char* eventName, TiEvent* event)
{
    TiEventContainer* container;
    if (events_.contains(eventName)) {
        container = events_[eventName]->container();
    } else {
        TiEventContainerFactory* factory = TitaniumRuntime::instance()->objectFactory()->getEventContainerFactory();
        container = factory->createEventContainer();
        events_.insert(eventName, EventPairSmartPtr(container, NULL));
    }

    event->setId(getNextEventId());
    container->addListener(event);
    return NATIVE_ERROR_OK;
}