Example #1
0
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;
}
Example #2
0
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;
}