int LWF::AddButtonEventHandler(string instanceName, const ButtonEventHandlerDictionary &h, ButtonKeyPressHandler kh) { if (h.empty()) return -1; int instId = SearchInstanceId(GetStringId(instanceName)); if (instId >= 0) return AddButtonEventHandler(instId, h, kh); if (instanceName.find('.') == string::npos) return -1; SetInteractive(); ButtonEventHandlersDictionary::iterator it = m_buttonEventHandlersByFullName.find(instanceName); if (it == m_buttonEventHandlersByFullName.end()) { m_buttonEventHandlersByFullName[instanceName] = ButtonEventHandlers(); it = m_buttonEventHandlersByFullName.find(instanceName); } int id = GetEventOffset(); it->second.Add(id, h, kh); Button *b = SearchButtonInstance(instId); if (b) b->AddHandlers(&it->second); return id; }
int LWF::AddMovieEventHandler( string instanceName, const MovieEventHandlerDictionary &h) { if (h.empty()) return -1; int instId = SearchInstanceId(GetStringId(instanceName)); if (instId >= 0) return AddMovieEventHandler(instId, h); if (instanceName.find('.') == string::npos) return -1; MovieEventHandlersDictionary::iterator it = m_movieEventHandlersByFullName.find(instanceName); if (it == m_movieEventHandlersByFullName.end()) { m_movieEventHandlersByFullName[instanceName] = MovieEventHandlers(); it = m_movieEventHandlersByFullName.find(instanceName); } int id = GetEventOffset(); it->second.Add(id, h); Movie *m = SearchMovieInstance(instId); if (m) m->AddHandlers(&it->second); return id; }
int LWF::AddEventHandler(int eventId, EventHandler eventHandler) { if (eventId < 0 || eventId >= (int)data->events.size()) return -1; int id = GetEventOffset(); m_eventHandlers[eventId].push_back(make_pair(id, eventHandler)); return id; }
int LWF::AddMovieEventHandler( int instId, const MovieEventHandlerDictionary &h) { if (instId < 0 || instId >= (int)data->instanceNames.size()) return -1; int id = GetEventOffset(); m_movieEventHandlers[instId].Add(id, h); Movie *m = SearchMovieInstanceByInstanceId(instId); if (m) m->AddHandlers(&m_movieEventHandlers[instId]); return id; }
int LWFCore::AddButtonEventHandler( int instId, const ButtonEventHandlerDictionary &h, ButtonKeyPressHandler kh) { if (instId < 0 || instId >= (int)data->instanceNames.size()) return -1; int id = GetEventOffset(); m_buttonEventHandlers[instId].Add(id, h, kh); Button *b = SearchButtonInstanceByInstanceId(instId); if (b) b->AddHandlers(&m_buttonEventHandlers[instId]); return id; }
int LWF::AddEventHandler(string eventName, EventHandler eventHandler) { int eventId = SearchEventId(eventName); int id; if (eventId >= 0 && eventId < (int)data->events.size()) { id = AddEventHandler(eventId, eventHandler); } else { GenericEventHandlerDictionary::iterator it = m_genericEventHandlerDictionary.find(eventName); if (it == m_genericEventHandlerDictionary.end()) { m_genericEventHandlerDictionary[eventName] = EventHandlerList(); it = m_genericEventHandlerDictionary.find(eventName); } id = GetEventOffset(); it->second.push_back(make_pair(id, eventHandler)); } return id; }
int LWF::AddExecHandler(ExecHandler execHandler) { int id = GetEventOffset(); m_execHandlers.push_back(make_pair(id, execHandler)); return id; }